express-next
A modern way for using Express.
Last updated 2 years ago by chrisyipw .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install express-next 
SYNC missed versions from official npm registry.

express-next

NPM version Dependency Status Travis CI Coveralls

A modern way for using Express.

This package adds the following feature(s) to Express:

Environment Requirement

  • node >= 0.12 with --harmony
  • iojs >= 1.0.0
  • Express >= 4.5 (only this version tested, should work for 4.x)

Usage

npm install --save express express-next
const express = require('express-next')
const app = express()
const router = express.Router()

// Normal function works as usual
app.get('/', function (req, res) {
  res.render('index')
})

app.use('/users', router)

// Generator function works as well
router.get('/:id', function* (req, res) {
  let user = yield User.find(req.params.id)

  if (user) {
    res.locals.user = user
    res.render('user')
  } else {
    // Equals to "next(new Error(`User ${req.params.id} not found!`))"
    throw new Error(`User ${req.params.id} not found!`)
  }
})

Contributors

Via GitHub

Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
  • co ^4.5.4
Dev Dependencies (6)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |