mirror of
https://github.com/shadcn-ui/taxonomy
synced 2026-05-23 17:28:23 +00:00
11 lines
339 B
TypeScript
11 lines
339 B
TypeScript
import type { NextApiHandler, NextApiRequest, NextApiResponse } from "next"
|
|
|
|
export function withMethods(methods: string[], handler: NextApiHandler) {
|
|
return async function (req: NextApiRequest, res: NextApiResponse) {
|
|
if (!methods.includes(req.method)) {
|
|
return res.status(405).end()
|
|
}
|
|
|
|
return handler(req, res)
|
|
}
|
|
}
|