zoom

0.0.2 • Public • Published

Zoom

Provides a consitent interface that mirrors Boom

// Here's the code in full
'use strict';
 
function Zoom(data, statusCode) {
  this.data = data;
  this.statusCode = statusCode || 200;
}
Zoom.create = function(data) {
  return new Zoom(data);
}
 
module.exports = Zoom;

Usage

 
function handler(request, reply) {
  doAsync(function(err, result) {
 
    if (err) {
      return reply(Boom.badImplementation(err, 'Something went wrong'));
    }
    return Zoom.create(result);
  })
}
 
// This would yield
{
  "statusCode": 200,
  "data": {
    "foo": true,
    "bar": 42
  }
}
 
// If an error occured, the (Boom) response would look like
{
  "statusCode": 400,
  "error": "whatever",
  "message": "Something went wrong",
}

/zoom/

    Package Sidebar

    Install

    npm i zoom

    Weekly Downloads

    29

    Version

    0.0.2

    License

    ISC

    Last publish

    Collaborators

    • tommygaessler