Files
speckle-server/packages/server/modules/cli/commands/bull/test-consume.ts
T
Iain Sproat 4d01e13a84 feat(structured logging) (#1242)
* Revert "Revert structured logging 2 (#1240)"
This reverts commit 78ecaeffcb.
* Logging should not be bundled into core shared directory
* making sure observability stuff isnt bundled into frontend


Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
2022-12-06 11:51:18 +00:00

30 lines
940 B
TypeScript

import { cliLogger } from '@/logging/logging'
import { NotificationType } from '@/modules/notifications/helpers/types'
import { initializeConsumption } from '@/modules/notifications/index'
import { get, noop } from 'lodash'
import { CommandModule } from 'yargs'
const command: CommandModule = {
command: 'test-consume',
describe: 'Consume incoming messages inserted through test-push',
handler: async () => {
cliLogger.info('Starting consumption...')
// Overriding handler for test purposes, we don't want the actual mentions logic to run
await initializeConsumption({
[NotificationType.MentionedInComment]: async (msg, { logger, job }) => {
logger.info('Received test message with payload', msg, job)
if (get(msg.data, 'error')) {
throw new Error('Forced to throw error!')
}
}
})
// Prevent script from exiting
await new Promise(noop)
}
}
export = command