Skip to content

selfcontained/hapi-boom-jsend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

hapi-boom-jsend

hapi plugin to convert boom errors into jsend responses

npm install hapi-boom-jsend

4XX responses

4XX responses created by boom are converted into jsend fail responses. The error and statusCode properties are left on the payload, while the others are coerced into jsend properties.

Before

{
  "statusCode": 401,
  "error": "Unauthorized",
  "message": "your message"
}

After

{
  "status": "fail",
  "error": "Unauthorized",
  "statusCode": 401,
  "data": { "message": "your message" }
}

5XX responses

5XX responses created by boom are converted into jsend error responses. The error, statusCode, and message properties are left on the payload. status and data are added as well.

Before

{
  "statusCode": 502,
  "error": "Bad Gateway",
  "message": "An internal server error occurred"
}

After

{
  "status": "error",
  "error": "Bad Gateway",
  "statusCode": 502,
  "data": {},
  "message": "An internal server error occurred"
}

About

Convert hapi boom errors into jsend responses

Resources

License

Stars

Watchers

Forks

Packages

No packages published