express-route-descriptor

Allows you to represent a route as an object and gives you a methods to easily inject it into Express.js router.

Express-route-descriptor

Allows you to represent a route as an object and gives you a methods to easily inject it into Express.js router.

npm install express-route-descriptor
var routeDescriptor = require('express-route-descriptor');
var express = require('express');
var app = express();
 
var controller = {
foofunction (reqres) {
res.send(200);
}
};
 
var descriptors = routeDescriptor.createRouteDescriptors([{
path: '/foo',
handler: controller.foo
}, {
path: '*',
method: 'all',
handlerfunction (reqres) {
res.send(404);
}
}]);
 
routeDescriptor.injectRouteDescriptors(app, descriptors);
 
app.listen(3000);

Go to http://localhost:3000/foo and http://localhost:3000/bar to see that it works.

grunt test