An open API service indexing awesome lists of open source software.

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

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