Bring annotation routing to expressJs
$ npm install --save express-annotation
given a file /controllers/user.js
:
// @route('/users')
module.exports.getAll = function(req, res){
};
// @route('/users/:id')
module.exports.get = fucntion(req, res){
console.log(req.params.id);
};
// @httpPut()
// @route('/users/:id')
module.exports.update = function(req, res){
};
you can register those routes by writing so:
var expressAnnotation = require('express-annotation');
var app = require('express')();
expressAnnotation(app, 'controllers/**/*.js', function(err){
// routes have been added to the express instance
app.listen(3030);
});
required
express instance (value returned by:
express()
)
required
Type: array
, string
Type: Function
will be called when all the routes have been added to the express instance
MIT © Thomas Sileghem