I currently use postgresql-node in my lambda with
import { Client } from 'pg'
I want to instrument the Postgresql lib with AWS X-ray. The Nodejs example has this line:
var AWSXRay = require('aws-xray-sdk');
var pg = AWSXRay.capturePostgres(require('pg'));
How would I convert the second line in that to proper Typescript. All the variations I come up with produce some errors or warnings. For example I would guess this would work:
const pg = AWSXRay.capturePostgres(require('pg'))
but not only you get ESlint warning for require
being used without import
but after that pg.Client
says pg namespace not found
.
Well, it's slightly ugly but this seems to work:
import * as pg from 'pg'
const patchedPg = AWSXRay.capturePostgres(pg)