You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
253 B
JavaScript

import { isValidObjectId } from "mongoose";
function checkId( req, res, next ) {
if(!isValidObjectId(req.params.id)){
res.status(404)
throw new Error(`Invalid Object of: ${req.params.id}`)
}
next()
}
export default checkId