New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

promisify-express

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promisify-express

A lightweight wrapper for Express 4's Router that allows middleware to return promises

  • 4.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

promisify-express

This package allows you to wrap express so that you can use promises as handlers, and any promise error will be neatly passed to express error handlers.

Getting Started

Install the module with: npm install promisify-express --save.

Documentation

Middleware and route handlers can simply return a promise. If the promise is rejected, promisify-express will call next with the reason. This functionality removes the need to explicitly define a rejection handler.

// Without promisify-express
const express = require('express')
const app = express()

app.get('/url', async (req, res, next) => {
  try {
    throw new Error('something went wrong')
  } catch (e) {
    next(e)
  }
})

app.use((err, req, res, next) => {
  console.error(err)
  res.status(500).send(err.message)
})

// With promisify-express
const express = require('express')
const promisifyExpress = require('promisify-express')
const app = express()
promisifyExpress(app)

app.get('/url', async (req, res, next) => {
  throw new Error('something went wrong')
})

app.use((err, req, res, next) => {
  console.error(err)
  res.status(500).send(err.message)
})

Keywords

FAQs

Package last updated on 10 Apr 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