express-route-resolver
v0.0.3
Published
Resolver simplified of routes for Express
Downloads
2
Maintainers
Readme
express-route-resolver
Installation
Using NPM
npm install --save express-route-resolver
Usage
import
import routeResolver from 'express-route-resolver';
or
const routeResolver = require('express-route-resolver');
onCreate
app.route('/my-route')
.post((req, res) => {
const promise = Promise.resolve(req.body);
routeResolver.onCreate(res, promise);
});
onDelete
app.route('/my-route/:id')
.delete((req, res) => {
const promise = Promise.resolve(req.params.id);
routeResolver.onDelete(res, promise);
});
onError
app.use((err, req, res, next) => {
routeResolver.onError(res, err);
});
onFind
app.route('/my-route')
.get((req, res) => {
const promise = Promise.resolve(req.query);
routeResolver.onFind(res, promise);
});
onFindOne
app.route('/my-route/:id')
.get((req, res) => {
const promise = Promise.resolve(req.params.id);
routeResolver.onFindOne(res, promise);
});
onUpdate
app.route('/my-route/:id')
.put((req, res) => {
const promise = Promise.resolve(req.params.id);
routeResolver.onUpdate(res, promise);
});
License
The express-route-resolver
project is under MIT license.