Comparing version 0.0.1 to 0.0.2
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
function Zoom(data, statusCode) { | ||
@@ -2,0 +4,0 @@ this.data = data; |
{ | ||
"name": "zoom", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Like hapijs boom but for non-error return data", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# Zoom | ||
Provides a consitent interface that mirrors Boom | ||
```js | ||
// 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 | ||
```js | ||
function handler(request, reply) { | ||
@@ -9,3 +26,3 @@ doAsync(function(err, result) { | ||
if (err) { | ||
return reply(Boom.badImplementation(err)); | ||
return reply(Boom.badImplementation(err, 'Something went wrong')); | ||
} | ||
@@ -16,2 +33,17 @@ 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", | ||
} | ||
``` |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
1109
9
48