0.1.3 • Published 8 years ago

super-boom v0.1.3

Weekly downloads
1
License
ISC
Repository
bitbucket
Last release
8 years ago

About

Super-boom enhance the Hapi.js Boom package by allowing to add parameters in the body of the HTTP answer.

Installation

$ npm install super-boom --save

How to use

In your project file, include the package:

$ Boom = require('super-boom')({ origin: 'server1' }),

where the parameter are the optional default parameters (for now only origin is possible)

Boom.badRequest(httpCode, message, customCode, parameters, details)

In your code, you can now throw error like this:

$ Boom.customCode(403, 'This property already exist', "CUST_ERR_CODE", ['Some value', 'Blah'], { param1: 'blah', test: 2 }, 'server2');

The body of the HTTP answer should now look like this:

{"statusCode":403,"message":"This property already exist","code":"CUST_ERR_CODE","parameters":"Some value","Blah", { param1: 'blah', test: 2 }, origin : 'server2' }

Where:

  • httpCode: http code returned by the server
  • message: a meaningful string that explain the problem to your users that only use your API
  • customCode: your application code (which is different from http code) that refer to the exact problem. This code can be plugged in a frontend dictionary.
  • parameters: array of strings to be plugged in the frontend dictionary with the customCode
  • details: an object that can contain anything. Sometimes, you want your API to return additional details that can be used by the frontend.
  • origin: the service or server who emitted the error
0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago