Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

zoom

tommygaessler128ISCdeprecated0.0.3

WARNING: This package has moved. Please see the latest official package here https://www.npmjs.com/package/@zoom/rivet, thank you

Like hapijs boom but for non-error return data

readme

THIS PACKAGE IS DEPRECATED

Please see the latest official package @zoom/rivet, thank you!


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",
}