import * as knexInit from 'knex' ; import * as knexStringcase from 'knex-stringcase' ; import config from '../config' ; import { handleDatabaseError } from '../utils/errors' ; const knexConfig = { client : 'pg' , connection : config . database . connection , pool : { param conn param done afterCreate ( conn , done ) { conn . query ( 'SET timezone="UTC";' , async ( err ? ) => { if ( err ) { return done ( err , conn ) ; } conn . query ( 'SET statement_timeout TO 3000;' , async ( error ) => { done ( error , conn ) ; } ) ; return undefined ; } ) ; } , } , } ; const knex = knexInit ( knexStringcase ( knexConfig ) ) ; knex . on ( 'query-error' , ( error ) => { handleDatabaseError ( error ) ; } ) ; export default knex ;