Scheduling infrastructure for absolutely everyone.
Update to message for invalid method (#5038)
Alex van Andelb7161694a587
diff --git a/packages/lib/server/defaultHandler.ts b/packages/lib/server/defaultHandler.tsindex bd2b2c4a92c..ded7ad99564 100644--- a/packages/lib/server/defaultHandler.ts+++ b/packages/lib/server/defaultHandler.ts@@ -4,11 +4,15 @@ type Handlers = {[method in "GET" | "POST" | "PATCH" | "PUT" | "DELETE"]?: Promise<{ default: NextApiHandler }>;};-/** Allows us to split big API handlers by method and auto catch unsupported methods */+/** Allows us to split big API handlers by method */const defaultHandler = (handlers: Handlers) => async (req: NextApiRequest, res: NextApiResponse) => {const handler = (await handlers[req.method as keyof typeof handlers])?.default;-- if (!handler) return res.status(405).json({ message: "Method not allowed" });+ // auto catch unsupported methods.+ if (!handler) {+ return res+ .status(405)+ .json({ message: `Method Not Allowed (Allow: ${Object.keys(handlers).join(",")})` });+ }try {await handler(req, res);