2022-06-03 10:54:30 +02:00
|
|
|
import express from 'express'
|
2021-03-10 09:09:04 +01:00
|
|
|
|
|
|
|
const methodsValidator = (methods: string[]) => {
|
|
|
|
return (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
|
|
|
if (methods.includes(req.method) !== true) {
|
|
|
|
return res.sendStatus(405)
|
|
|
|
}
|
|
|
|
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
methodsValidator
|
|
|
|
}
|