import postgres from 'postgres' ; import { DB_POSTGRES_END_TIMEOUT , DB_POSTGRES_CONFIG , DB_POSTGRES_CUSTOM_TYPES } from 'config/db' ; export let sql = null ; export function InitSql ( ) { sql = postgres ( DB_POSTGRES_CONFIG ) ; } export async function ShutdownSql ( ) { await sql . end ( { timeout : DB_POSTGRES_END_TIMEOUT } ) ; } export function ToPostgresError ( obj ) { if ( obj instanceof sql . PostgresError ) { return obj as postgres . Error ; } return null ; }