Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return function postgres(next) {
const pool = new Pool(
...(url
? [
{
connectionString: url
}
]
: [])
);
const namespace = createNamespace('postgres');
orm.setConnection(async () => {
const connector = namespace.get('getConnection');
if (typeof connector !== 'function') {
throw new Error(
'Accessing postgres outside the context of a request? UNACCEPTABLE'
);
}
const connection = await connector();
return {
connection,
release() {}
};
});
return async function inner(context) {
let client = null;