Skip to content

Commit

Permalink
feat(adapter): pass body
Browse files Browse the repository at this point in the history
  • Loading branch information
Diluka committed May 17, 2024
1 parent d10fae6 commit 98c5c79
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/express/src/ExpressAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class ExpressAdapter implements IServerAdapter {
throw new Error(`Please call 'setQueues' before using 'registerPlugin'`);
}
const router = Router();
router.use(express.json());

routes.forEach((route) =>
(Array.isArray(route.method) ? route.method : [route.method]).forEach(
Expand All @@ -63,6 +64,7 @@ export class ExpressAdapter implements IServerAdapter {
queues: this.bullBoardQueues as BullBoardQueues,
query: req.query,
params: req.params,
body: req.body,
});

res.status(response.status || 200).json(response.body);
Expand Down
1 change: 1 addition & 0 deletions packages/fastify/src/FastifyAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export class FastifyAdapter implements IServerAdapter {
queues: this.bullBoardQueues as any,
params: request.params as any,
query: request.query as any,
body: request.body as any,
});

return reply.status(response.status || 200).send(response.body);
Expand Down
12 changes: 7 additions & 5 deletions packages/h3/src/H3Adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ import {
AppViewRoute,
BullBoardQueues,
ControllerHandlerReturnType,
HTTPMethod,
IServerAdapter,
UIConfig,
} from '@bull-board/api/dist/typings/app';
import ejs from 'ejs';
import { readFileSync, statSync } from 'fs';
import { resolve, normalize } from 'node:path';
import {
createError,
createRouter,
eventHandler,
getRouterParams,
getQuery,
getRouterParams,
readBody,
serveStatic,
createError,
} from 'h3';
import ejs from 'ejs';
import { normalize, resolve } from 'node:path';
import { getContentType } from './utils/getContentType';
import { HTTPMethod } from '@bull-board/api/dist/typings/app';

export class H3Adapter implements IServerAdapter {
private uiHandler = createRouter();
Expand Down Expand Up @@ -183,6 +184,7 @@ export class H3Adapter implements IServerAdapter {
queues: this.bullBoardQueues as BullBoardQueues,
params: getRouterParams(event),
query: getQuery(event),
body: readBody(event),
});

return body;
Expand Down
1 change: 1 addition & 0 deletions packages/hapi/src/HapiAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class HapiAdapter implements IServerAdapter {
queues: this.bullBoardQueues as any,
params: request.params as any,
query: request.query as any,
body: request.payload as any,
});

return h.response(response.body).code(response.status || 200);
Expand Down
1 change: 1 addition & 0 deletions packages/hono/src/HonoAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export class HonoAdapter implements IServerAdapter {
queues: bullBoardQueues,
params: c.req.param(),
query: c.req.query(),
body: c.req.json(),
});
if (response.status == 204) return c.body(null, 204);
return c.json(response.body, response.status || 200);
Expand Down
1 change: 1 addition & 0 deletions packages/koa/src/KoaAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class KoaAdapter implements IServerAdapter {
queues: this.bullBoardQueues as any,
params: ctx.params,
query: ctx.query,
body: ctx.body,
});

ctx.status = response.status || 200;
Expand Down

0 comments on commit 98c5c79

Please sign in to comment.