Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    express-route-descriptorpublic

    Express-route-descriptor Build Status

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

    Installation

    npm install express-route-descriptor
    

    Example

    var routeDescriptor = require('express-route-descriptor');
    var express = require('express');
    var app = express();
     
    var controller = {
        foo: function (req, res) {
            res.send(200);
        }
    };
     
    var descriptors = routeDescriptor.createRouteDescriptors([{
        path: '/foo',
        handler: controller.foo
    }, {
        path: '*',
        method: 'all',
        handler: function (req, res) {
            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.

    Tests

    grunt test

    Keywords

    none

    install

    npm i express-route-descriptor

    Downloadsweekly downloads

    3

    version

    0.0.1

    license

    none

    repository

    github.com

    last publish

    collaborators

    • avatar