2022-03-29 00:25:24 +00:00
|
|
|
import { label } from "next-api-middleware";
|
2022-03-30 12:17:55 +00:00
|
|
|
|
2022-03-29 00:25:24 +00:00
|
|
|
import { addRequestId } from "./addRequestid";
|
|
|
|
import { captureErrors } from "./captureErrors";
|
2022-04-07 01:29:53 +00:00
|
|
|
import {
|
|
|
|
HTTP_POST,
|
|
|
|
HTTP_DELETE,
|
|
|
|
HTTP_PATCH,
|
|
|
|
HTTP_GET,
|
|
|
|
HTTP_GET_OR_POST,
|
|
|
|
HTTP_GET_DELETE_PATCH,
|
|
|
|
} from "./httpMethods";
|
2022-03-29 00:25:24 +00:00
|
|
|
import { verifyApiKey } from "./verifyApiKey";
|
2022-03-30 12:17:55 +00:00
|
|
|
|
2022-03-29 00:25:24 +00:00
|
|
|
const withMiddleware = label(
|
|
|
|
{
|
2022-04-07 01:29:53 +00:00
|
|
|
HTTP_GET_OR_POST,
|
2022-04-03 22:49:05 +00:00
|
|
|
HTTP_GET_DELETE_PATCH,
|
2022-03-30 12:17:55 +00:00
|
|
|
HTTP_GET,
|
|
|
|
HTTP_PATCH,
|
|
|
|
HTTP_POST,
|
|
|
|
HTTP_DELETE,
|
2022-03-29 00:25:24 +00:00
|
|
|
addRequestId,
|
|
|
|
verifyApiKey,
|
2022-03-30 12:17:55 +00:00
|
|
|
sentry: captureErrors,
|
2022-03-29 00:25:24 +00:00
|
|
|
},
|
2022-04-01 15:53:52 +00:00
|
|
|
["sentry", "verifyApiKey", "addRequestId"] // <-- Provide a list of middleware to call automatically
|
2022-03-29 00:25:24 +00:00
|
|
|
);
|
|
|
|
|
2022-03-30 12:17:55 +00:00
|
|
|
export { withMiddleware };
|