-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure-modules.js
30 lines (25 loc) · 991 Bytes
/
configure-modules.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const pino = require('pino')
// const { createMessageStore } = require('gearshaft/message-store/memory')
const { createMessageStore } = require('gearshaft/message-store/postgres')
const { createPostgresGateway } = require('gearshaft/postgres-gateway')
const { createWriter } = require('gearshaft/messaging')
exports.configureModules = (config) => {
const log = pino(config.log)
const postgresGateway = createPostgresGateway(config.postgres)
postgresGateway.on('error', (err) => {
// prevent exposing postgres credentials and clogging up logs
// https://github.com/brianc/node-postgres/issues/1568
delete err.client
log.error({ err }, 'postgres connection error')
})
const gearshaftLog = log.child(config.gearshaft.log)
const messageStore = createMessageStore({ log: gearshaftLog, postgresGateway })
const write = createWriter({ log: gearshaftLog, messageStore })
return {
gearshaftLog,
log,
messageStore,
postgresGateway,
write
}
}