From dc50dcc8084c14382b51c26d81c5b523e8874ae1 Mon Sep 17 00:00:00 2001 From: Lorenzo Palaia Date: Fri, 19 Jan 2024 00:08:51 +0100 Subject: [PATCH] fixed merge conflicts issues --- apps/server/src/app/app.ts | 1 + apps/server/src/app/routes/admin.router.ts | 33 ++++++++++++++++++++++ apps/server/src/app/routes/index.ts | 1 + apps/workers/src/main.ts | 1 + 4 files changed, 36 insertions(+) create mode 100644 apps/server/src/app/routes/admin.router.ts diff --git a/apps/server/src/app/app.ts b/apps/server/src/app/app.ts index 58c2a568..f806b4d8 100644 --- a/apps/server/src/app/app.ts +++ b/apps/server/src/app/app.ts @@ -43,6 +43,7 @@ import { toolsRouter, publicRouter, e2eRouter, + adminRouter, } from './routes' import env from '../env' diff --git a/apps/server/src/app/routes/admin.router.ts b/apps/server/src/app/routes/admin.router.ts new file mode 100644 index 00000000..dd17b6d9 --- /dev/null +++ b/apps/server/src/app/routes/admin.router.ts @@ -0,0 +1,33 @@ +import { Router } from 'express' +import { auth, claimCheck } from 'express-openid-connect' +import { createBullBoard } from '@bull-board/api' +import { BullAdapter } from '@bull-board/api/bullAdapter' +import { ExpressAdapter } from '@bull-board/express' +import { AuthUtil, BullQueue } from '@maybe-finance/server/shared' +import { SharedType } from '@maybe-finance/shared' +import { queueService } from '../lib/endpoint' +import env from '../../env' +import { validateAuthJwt } from '../middleware' + +const router = Router() + +const serverAdapter = new ExpressAdapter().setBasePath('/admin/bullmq') + +createBullBoard({ + queues: queueService.allQueues + .filter((q): q is BullQueue => q instanceof BullQueue) + .map((q) => new BullAdapter(q.queue)), + serverAdapter, +}) + +router.get('/', validateAuthJwt, (req, res) => { + res.render('pages/dashboard', { + user: req.user?.name, + role: 'Admin', + }) +}) + +// Visit /admin/bullmq to see BullMQ Dashboard +router.use('/bullmq', validateAuthJwt, serverAdapter.getRouter()) + +export default router diff --git a/apps/server/src/app/routes/index.ts b/apps/server/src/app/routes/index.ts index 0bad8b5a..f33aa669 100644 --- a/apps/server/src/app/routes/index.ts +++ b/apps/server/src/app/routes/index.ts @@ -14,3 +14,4 @@ export { default as plansRouter } from './plans.router' export { default as toolsRouter } from './tools.router' export { default as publicRouter } from './public.router' export { default as e2eRouter } from './e2e.router' +export { default as adminRouter } from './admin.router' \ No newline at end of file diff --git a/apps/workers/src/main.ts b/apps/workers/src/main.ts index e2d85834..d9308590 100644 --- a/apps/workers/src/main.ts +++ b/apps/workers/src/main.ts @@ -16,6 +16,7 @@ import { workerErrorHandlerService, } from './app/lib/di' import env from './env' +import { cleanUpOutdatedJobs } from './utils' // Defaults from quickstart - https://docs.sentry.io/platforms/node/ Sentry.init({