Created
April 14, 2023 18:56
-
-
Save MichaelrMentele/c24a06c4e3402848fb920206115bdc29 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# app.ts | |
import path from 'path' | |
import { config } from 'dotenv-defaults' | |
import express from 'express' | |
import { setup as setupAdminJS } from './adminjs/setup' | |
import { setup as setupBullBoard } from './bullboard/setup' | |
const PORT = 8912 | |
config({ | |
path: path.resolve(__dirname, '../../.env'), | |
defaults: path.resolve(__dirname, '../../.env.defaults'), | |
multiline: true, | |
}) | |
const start = async () => { | |
const app = express() | |
setupAdminJS(app) | |
setupBullBoard(app) | |
app.use('/health', (_req, res) => res.send('OK')) | |
app.listen(PORT, () => { | |
console.log(`Admin started on http://localhost:${PORT}`) | |
}) | |
} | |
start() | |
# bullboard/setup.ts | |
import { | |
ExpressAdapter, | |
createBullBoard, | |
BullMQAdapter, | |
} from '@bull-board/express' | |
import { Queue } from 'bullmq' | |
import { Express } from 'express' | |
import { useBasicAuth } from '../useBasicAuth' | |
import { getConnection } from './connection' | |
const QUEUE_NAMES = [ | |
'checkInsuranceEligibility', | |
'downloadOutboundFax', | |
'generateAppointmentNotification', | |
'receiveFax', | |
'remindUpcomingAppointments', | |
'sendFax', | |
'sendTextMessage', | |
'triggerInsuranceEligibilityChecks12hour', | |
'triggerInsuranceEligibilityChecks72hour', | |
] | |
export const setup = (app: Express) => { | |
const serverAdapter = new ExpressAdapter() | |
serverAdapter.setBasePath('/queues') | |
createBullBoard({ | |
queues: QUEUE_NAMES.map( | |
(name) => | |
new BullMQAdapter( | |
new Queue(name, { | |
connection: getConnection(), | |
defaultJobOptions: { | |
attempts: 3, | |
backoff: { | |
type: 'exponential', | |
delay: 1000, | |
}, | |
}, | |
}) | |
) | |
), | |
serverAdapter: serverAdapter, | |
}) | |
app.use('/queues', useBasicAuth(), serverAdapter.getRouter()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment