From 5408c73dd72433cbd1cad0e9a5fe645df5a0aad3 Mon Sep 17 00:00:00 2001 From: Felix Mosheev <9304194+felixmosh@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:55:44 +0200 Subject: [PATCH] elysia style fix --- examples/with-elysia/index.ts | 8 ++++---- packages/elysia/README.md | 23 +++++++++++++++++++++++ packages/elysia/src/ElysiaAdapter.ts | 11 +++++------ 3 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 packages/elysia/README.md diff --git a/examples/with-elysia/index.ts b/examples/with-elysia/index.ts index af76637e..44435191 100644 --- a/examples/with-elysia/index.ts +++ b/examples/with-elysia/index.ts @@ -1,6 +1,6 @@ import { createBullBoard } from '@bull-board/api'; import { BullMQAdapter } from '@bull-board/api/bullMQAdapter'; -import { ElysiaAdapter } from '@bull-board/elysia'; +import { ElysiaAdapter } from '../../node_modules/@bull-board/elysia'; import { Queue as QueueMQ, Worker } from 'bullmq'; import Elysia from 'elysia'; @@ -14,7 +14,7 @@ const redisOptions = { const createQueueMQ = (name: string) => new QueueMQ(name, { connection: redisOptions }); -async function setupBullMQProcessor(queueName: string) { +function setupBullMQProcessor(queueName: string) { new Worker( queueName, async (job) => { @@ -34,7 +34,7 @@ async function setupBullMQProcessor(queueName: string) { const exampleBullMq = createQueueMQ('BullMQ'); -await setupBullMQProcessor(exampleBullMq.name); +setupBullMQProcessor(exampleBullMq.name); const serverAdapter = new ElysiaAdapter('/ui'); @@ -46,7 +46,7 @@ createBullBoard({ const app = new Elysia() .onError(({ error, code, request }) => { console.error(error, code, request.method, request.url); - if(code === "NOT_FOUND") return "NOT_FOUND"; + if (code === 'NOT_FOUND') return 'NOT_FOUND'; }) .use(serverAdapter.registerPlugin()) .get('/add', async ({ query }) => { diff --git a/packages/elysia/README.md b/packages/elysia/README.md new file mode 100644 index 00000000..cc4b3b6c --- /dev/null +++ b/packages/elysia/README.md @@ -0,0 +1,23 @@ +# @bull-board @bull-board/elysia + +[Elysia](https://expressjs.com/) server adapter for `bull-board`. + +

+ + npm version + + + npm downloads + + + licence + +

+ +![Overview](https://raw.githubusercontent.com/felixmosh/bull-board/master/screenshots/overview.png) +![UI](https://raw.githubusercontent.com/felixmosh/bull-board/master/screenshots/dashboard.png) + +# Usage examples +1. [Simple express setup](https://github.com/felixmosh/bull-board/tree/master/examples/with-elysia) + +For more info visit the main [README](https://github.com/felixmosh/bull-board#readme) diff --git a/packages/elysia/src/ElysiaAdapter.ts b/packages/elysia/src/ElysiaAdapter.ts index 5d260c7e..182f51ff 100644 --- a/packages/elysia/src/ElysiaAdapter.ts +++ b/packages/elysia/src/ElysiaAdapter.ts @@ -15,6 +15,11 @@ export class ElysiaAdapter implements IServerAdapter { name: '@bull-board/elysia', }).as('plugin'); private basePath = ''; + private entryRoute: AppViewRoute | undefined; + private statics: { path: string; route: string } | undefined; + private bullBoardQueues: BullBoardQueues | undefined; + private viewPath: string | undefined; + private uiConfig: UIConfig = {}; constructor(basePath = '') { if (basePath.length) { @@ -26,12 +31,6 @@ export class ElysiaAdapter implements IServerAdapter { } } - private entryRoute: AppViewRoute | undefined; - private statics: { path: string; route: string } | undefined; - private bullBoardQueues: BullBoardQueues | undefined; - private viewPath: string | undefined; - private uiConfig: UIConfig = {}; - public setStaticPath(staticsRoute: string, staticsPath: string): ElysiaAdapter { this.statics = { route: staticsRoute, path: staticsPath };