Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapi-dev-errors

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-dev-errors - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

test/plugin-falls-back-to-json.js

3

CHANGELOG.md
# Changelog
## Version 2.2.0 (2018-06-02)
- `add` JSON response for CLI requests (cURL, Postman, wget) (thank you @pi0)
## Version 2.1.0 (2018-02-12)

@@ -4,0 +7,0 @@ - `add` status code to Youch error and show it in the view

@@ -39,2 +39,5 @@ 'use strict'

// helper function to test if string matches a value
const matches = (str, regex) => str && str.match(regex)
// extend the request lifecycle at `onPreResponse`

@@ -49,2 +52,3 @@ // to change the default error handling behavior (if enabled)

const accept = request.raw.req.headers.accept
const agent = request.raw.req.headers['user-agent']
const statusCode = error.output.statusCode

@@ -63,4 +67,13 @@

// take priority: check header if request is in CLI
if (matches(agent, /curl|wget|postman/i)) {
const formattedJSON = JSON.stringify(Object.assign({}, errorResponse, {
stacktrace: errorResponse.stacktrace.replace(/<\/?mark>/g, '').split('\n').map(s => s.trim())
}), null, 2)
return h.response(formattedJSON).code(statusCode).type('application/json')
}
// take priority: check header if there’s a JSON REST request
if (accept && accept.match(/json/)) {
if (matches(accept, /json/)) {
return h.response(errorResponse).code(statusCode)

@@ -67,0 +80,0 @@ }

2

package.json
{
"name": "hapi-dev-errors",
"description": "Return better error details and skip the look at command line to catch the issue.",
"version": "2.1.0",
"version": "2.2.0",
"author": "Future Studio <info@futurestud.io>",

@@ -6,0 +6,0 @@ "bugs": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc