Socket
Socket
Sign inDemoInstall

middy

Package Overview
Dependencies
40
Maintainers
8
Versions
147
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.26.0 to 0.27.0

2

package.json
{
"name": "middy",
"version": "0.26.0",
"version": "0.27.0",
"description": "🛵 The stylish Node.js middleware engine for AWS Lambda",

@@ -5,0 +5,0 @@ "main": "./index.js",

@@ -23,2 +23,21 @@ const middy = require('../../middy')

test('It should create a response for HTTP errors created with a generic error', () => {
const handler = middy((event, context, cb) => {
const err = new Error('A server error')
err.statusCode = 500
throw err
})
handler
.use(httpErrorHandler({ logger: false }))
// run the handler
handler({}, {}, (_, response) => {
expect(response).toEqual({
statusCode: 500,
body: 'A server error'
})
})
})
test('It should NOT handle non HTTP errors', () => {

@@ -25,0 +44,0 @@ const handler = middy((event, context, cb) => {

@@ -10,3 +10,5 @@ module.exports = (opts) => {

onError: (handler, next) => {
if (handler.error.constructor.super_ && handler.error.constructor.super_.name === 'HttpError') {
// if there are a `statusCode` and an `error` field
// this is a valid http error object
if (handler.error.statusCode && handler.error.message) {
if (typeof options.logger === 'function') {

@@ -13,0 +15,0 @@ options.logger(handler.error)

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc