Skip to content

eyy/express-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

express-tree

Hierarchical (almost-declarative) routing for express.

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'
    })
});

About

Hierarchical Router for Express.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published