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

    express-treepublic

    express-tree

    Hierarchical (almost-declarative) routing for express.js

    Plant

    npm i express-tree --save

    var express = require('express');
    require('express-tree');
     
    var app = express();

    Pluck

    app.tree({
        '': function(req, res) {          // => app.get('/', ...)
            res.send('hello forest.')
        },
        login: 'login',                   // => res.render('login');
        account: {
            '': 'account/index',          // => /account
            register: 'account/register', // => /account/register
            settings: [ logged, 'account/settings' ],  // middleware works too!
        },
        // POST, PUT, and DELETE works like this. Not recommended, though.
        'POST login': passport.authenticate('local', { 
            successRedirect: '/',
            failureRedirect: '/login',
            failureMessage: true,
            badRequestMessage: ''
        })
    });

    Keywords

    none

    install

    npm i express-tree

    Downloadsweekly downloads

    6

    version

    0.0.2

    license

    none

    repository

    githubgithub

    last publish

    collaborators

    • avatar