Socket
Socket
Sign inDemoInstall

boomify

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    boomify

A simple higher order component to handle errors using boom and express.


Version published
Weekly downloads
95
decreased by-41.36%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

boomify NPM version Build Status Dependency Status Coverage Status

A simple higher order component to handle errors using boom and express.

Installation

$ npm install --save boomify

Usage


var app = require('express')();
var boom = require('boom');
var boomify = require('boomify');

var ctrl = {
  findOne(req, res) => res.send(boom.notFound('could not find!')),
  morePractically(req, res) => {
    if(err) {
      // boomify will convert this to the appropriate response object
      return res.send(err); 
    }
    res.status(200);
    res.send({ foo: 'bar' });
  }
};

// boomify whole ctrl
app.get('/cats/findOne', boomify(ctrl).findOne);

// boomify a single method
boomify(ctrl, 'findOne');
app.get('/cats/findOne', ctrl.findOne);

// will convert boom.notFound to res.error(404); res.send(err.output.payload);

Tests

mocha test

License

Apache-2.0 © blugavere

Keywords

FAQs

Last updated on 12 Feb 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc