cal.pub0.org/lib/helpers/withMiddleware.ts

31 lines
669 B
TypeScript
Raw Normal View History

import { label } from "next-api-middleware";
2022-03-30 12:17:55 +00:00
import { addRequestId } from "./addRequestid";
import { captureErrors } from "./captureErrors";
import {
HTTP_POST,
HTTP_DELETE,
HTTP_PATCH,
HTTP_GET,
HTTP_GET_OR_POST,
HTTP_GET_DELETE_PATCH,
} from "./httpMethods";
import { verifyApiKey } from "./verifyApiKey";
2022-03-30 12:17:55 +00:00
const withMiddleware = label(
{
HTTP_GET_OR_POST,
HTTP_GET_DELETE_PATCH,
2022-03-30 12:17:55 +00:00
HTTP_GET,
HTTP_PATCH,
HTTP_POST,
HTTP_DELETE,
addRequestId,
verifyApiKey,
2022-03-30 12:17:55 +00:00
sentry: captureErrors,
},
["sentry", "verifyApiKey", "addRequestId"] // <-- Provide a list of middleware to call automatically
);
2022-03-30 12:17:55 +00:00
export { withMiddleware };