Skip to content

Commit

Permalink
chore: use workaround for Swatinem/rollup-plugin-dts#314
Browse files Browse the repository at this point in the history
  • Loading branch information
kravetsone committed Oct 25, 2024
1 parent aeea1c3 commit ead1259
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/webhook/adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ export interface FrameworkHandler {
}
export type FrameworkAdapter = (...args: any[]) => FrameworkHandler;

const responseOK = new Response("ok!") as Response;
const responseUnauthorized = new Response(WRONG_TOKEN_ERROR, {
status: 401,
}) as Response;

export const frameworks = {
elysia: ({ body, headers }) => ({
update: body,
header: headers[SECRET_TOKEN_HEADER],
unauthorized: () => new Response(WRONG_TOKEN_ERROR, { status: 401 }),
unauthorized: () => responseUnauthorized,
}),
fastify: (request, reply) => ({
update: request.body,
Expand Down Expand Up @@ -58,13 +63,13 @@ export const frameworks = {
"std/http": (req) => ({
update: req.json(),
header: req.headers.get(SECRET_TOKEN_HEADER),
response: () => new Response("ok!"),
unauthorized: () => new Response(WRONG_TOKEN_ERROR, { status: 401 }),
response: () => responseOK,
unauthorized: () => responseUnauthorized,
}),
"Bun.serve": (req) => ({
update: req.json(),
header: req.headers.get(SECRET_TOKEN_HEADER),
response: () => new Response("ok!"),
unauthorized: () => new Response(WRONG_TOKEN_ERROR, { status: 401 }),
response: () => responseOK,
unauthorized: () => responseUnauthorized,
}),
} satisfies Record<string, FrameworkAdapter>;

0 comments on commit ead1259

Please sign in to comment.