Created
August 11, 2021 17:15
-
-
Save jprivillaso/b7f69e1b04f22577c3a52f3eaafb6b09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Logger from 'bunyan'; | |
import PrettyStream from 'bunyan-pretty-colors'; | |
const logStream = new PrettyStream(); | |
logStream.pipe(process.stdout); | |
const log = Logger.createLogger({ | |
name: 'message-consumer', | |
streams: [{ | |
level: 'info', | |
type: 'raw', | |
stream: logStream | |
}] | |
}); | |
export const getLogger = (): Logger => log; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import knex, { Knex } from 'knex'; | |
import { getLogger } from '../services/logger'; | |
let client: Knex; | |
export const getClient = (): Knex => { | |
if (!client) { | |
client = knex({ | |
client: 'pg', | |
version: '7.2', | |
connection: { | |
host: process.env.POSTGRES_HOST, | |
user: process.env.POSTGRES_USER, | |
password: process.env.POSTGRES_PASSWORD, | |
database: process.env.POSTGRES_DB | |
} | |
}); | |
} | |
return client; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment