Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/diogo405/express-mongo-rest-sample


https://github.com/diogo405/express-mongo-rest-sample

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# express-mongo-rest-sample
A sample REST API using Node.js (Express) + MongoDB. It has all CRUD operations for a user entity ({"name": "Ayrton Senna"}).

## Architecture
The entry point is app.js which init the routes and the server. A request to the API has the flow "route -> service -> database".

E.g. GET /user
request -> userRoutes -> userService -> Mongodb.

All responses are wrapped in the ApiResponse class (id, success, payload, error). And all errors wrapped in the ApiError class.

Lastly, there's a exception handler to deal with uncaught errors (routes/handler.js).