Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

endpoint-handler

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

endpoint-handler

Express error and response handler when using Promises

latest
Source
npmnpm
Version
2.0.3
Version published
Weekly downloads
1.2K
53%
Maintainers
3
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 26 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts