https://github.com/logicco/mongoose-objectid-middleware
A REST API Node.js middleware that successfully throws 404 error instead of crashing server when Mongodb ObjectId is passed in request params
https://github.com/logicco/mongoose-objectid-middleware
expressjs javascript mongodb mongoose nodejs rest-api
Last synced: 3 months ago
JSON representation
A REST API Node.js middleware that successfully throws 404 error instead of crashing server when Mongodb ObjectId is passed in request params
- Host: GitHub
- URL: https://github.com/logicco/mongoose-objectid-middleware
- Owner: logicco
- Created: 2020-10-03T17:30:46.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-03T17:55:29.000Z (over 5 years ago)
- Last Synced: 2025-10-13T01:03:24.126Z (9 months ago)
- Topics: expressjs, javascript, mongodb, mongoose, nodejs, rest-api
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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);
```