Skip to content

mastilver/express-annotation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

express-annotation Build Status Coverage Status

Bring annotation routing to expressJs

Install

$ npm install --save express-annotation

Usage

given a file /controllers/user.js:


// @route('/users')
module.exports.getAll = function(req, res){

};

// @route('/users/:id')
module.exports.get = function(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);
});

API

expressAnnotation(expressInstance, paths, callback)

expressInstance

required

express instance (value returned by: express())

paths

required
Type: array, string

callback(err)

Type: Function

will be called when all the routes have been added to the express instance

Licence

MIT © Thomas Sileghem

About

Bring annotation routing to express

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published