endpoint-handler
Express error and response handler when using Promises
Last updated 5 months ago by development-producteca .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install endpoint-handler 
SYNC missed versions from official npm registry.

endpoint-handler

Express error and response handler when using Promises.

install

npm install endpoint-handler --save

usage

express = require("express")
controller = require("./controller")
router = express.Router()
{ route } = require("endpoint-handler") router

# router.use <<middleware>>

route.get "/", controller.get
route.put "/", controller.update

module.exports = router

features

  • if you return a successful Promise, it responds a 200 code with the json.
  • if you return a rejected Promise, it responds a 500 code with the error.
  • if you return a Promise that fails with an object { statusCode, body }, it responds a statusCode code with the body.
  • if you return a no-thenable, you are turning off the endpoint handler.

Current Tags

  • 2.0.3                                ...           latest (5 months ago)

5 Versions

  • 2.0.3                                ...           5 months ago
  • 2.0.2                                ...           7 months ago
  • 2.0.1                                ...           8 months ago
  • 2.0.0                                ...           8 months ago
  • 1.0.0                                ...           4 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (1)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |