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

boomware

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boomware

Opinionated Boom-based wrapper for asynchronous middleware

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

boomware

Opinionated Boom-based wrapper for asynchronous middleware (or handler) for Express, Connect, router, etc.

Installing

npm i --save boomware

Example

const boom = require('boom')
const boomware = require('boomware')
const express = require('express')

const app = express()

// Middleware can return a Promise (but it doesn't have to)
app.get('/async', boomware(async (req, res) => {
  if (Math.random() > 0.75) throw('Unexpected error!')
  if (Math.random() > 0.5) throw boom.serverUnavailable()
  res.send('OK!')
}))

app.use((err, req, res, next) => {
  console.error(err)
  res.status(err.output.statusCode).json(err.output.payload)
})

app.listen(3000)

API

boomware(fn)

Returns a middleware function that catches a thrown error, wraps it in an Boom.badImplementation if it's not already a Boom error, and passes it to the next() function. boomware handles the case whenfn return Promise, and the case when fn does not return a Promise.

License

MIT

Keywords

FAQs

Package last updated on 28 Jan 2020

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