express-router-zen
Write router for express is a different way
Last updated 7 months ago by akshendra .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install express-router-zen 
SYNC missed versions from official npm registry.

Route shorthand for express

Install

npm install -g express-router-gen

Usage

  const express = require('express');
  const app = express();
  const { better, wrap } = require('express-router-gen');

  // this is your controller
  const conf = {
    before: Function[], // middlewares to run before every route
    after: Function[], // middlewares to add after every route
    prefix: String, // prefix to add before every return 
    routes: {
      'get => /user/:id': function* (req, res, next) {},
      'post => /user': function (req, res, next) {},
      'put => /user/:id': {
        before: Function[],
        controller: function* (req, res, next) {},
      },
      'delete => /user/:id' => {
        before: Funtion[],
        after: Function[],
        controller: function (req, res, next) {},
      },
    },
  }

  // now use it
  app.use('/', better(conf));
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dependencies (3)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |