0.0.2 • Published 9 years ago

zoom v0.0.2

Weekly downloads
2
License
ISC
Repository
-
Last release
9 years ago

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

9 years ago

0.0.1

9 years ago

0.0.0

13 years ago