1.0.0 • Published 4 years ago
mongoose-objectid-middleware v1.0.0
What is it?
This middleware will successfully throw 404 error instead of crashing the server when invalid mongodb objectId is passed in param.
Installation
npm install mongoose-objectid-middleware
Usages
Your App.js
var objectIdMiddleware = require("mongoose-objectid-middleware");
app.get("/post/:post_id",objectIdMiddleware,appController.getPost);
app.get("/post/:post_id/comment/:comment_id",objectIdMiddleware,appController.getComment);
app.listen(8080);
1.0.0
4 years ago