Files
automatisch/packages/backend/src/helpers/inject-bull-board-handler.ts
2022-10-30 15:11:22 +01:00

33 lines
792 B
TypeScript

import { Application } from 'express';
import { ExpressAdapter } from '@bull-board/express';
import basicAuth from 'express-basic-auth';
import appConfig from '../config/app';
const injectBullBoardHandler = async (
app: Application,
serverAdapter: ExpressAdapter
) => {
if (
!appConfig.enableBullMQDashboard ||
!appConfig.bullMQDashboardUsername ||
!appConfig.bullMQDashboardPassword
)
return;
const queueDashboardBasePath = '/admin/queues';
serverAdapter.setBasePath(queueDashboardBasePath);
app.use(
queueDashboardBasePath,
basicAuth({
users: {
[appConfig.bullMQDashboardUsername]: appConfig.bullMQDashboardPassword,
},
challenge: true,
}),
serverAdapter.getRouter()
);
};
export default injectBullBoardHandler;