Skip to content

A REST API Node.js middleware that successfully throws 404 error instead of crashing server when Mongodb ObjectId is passed in request params

Notifications You must be signed in to change notification settings

logicco/mongoose-objectid-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

A REST API Node.js middleware that successfully throws 404 error instead of crashing server when Mongodb ObjectId is passed in request params

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published