Socket
Book a DemoInstallSign in
Socket

zoom

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zoom

Like hapijs boom but for non-error return data

latest
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 25 Nov 2024

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