Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

endpoint-handler

Package Overview
Dependencies
Maintainers
3
Versions
5
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

  • 2.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
211
increased by49.65%
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc