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

@middy/core

Package Overview
Dependencies
Maintainers
10
Versions
226
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@middy/core - npm Package Compare versions

Comparing version 1.0.0-beta.10 to 1.0.0-beta.11

61

__tests__/index.js

@@ -709,2 +709,63 @@ const middy = require('../')

// see issue #485 https://github.com/middyjs/middy/issues/485
test('It will keep invoking all the onError handlers if one of them resolves to a falsy value', (endTest) => {
const handler = middy((event, context) => {
throw new Error('something bad happened')
})
const middleware1 = {
onError: (handler) => {
handler.response = { error: handler.error }
return Promise.resolve()
}
}
const middleware2 = {
onError: (handler) => {
handler.response.middleware2_called = true
return Promise.resolve(handler.error)
}
}
handler
.use(middleware1)
.use(middleware2)
handler({}, {}, (err, response) => {
expect(err).toBeNull()
expect(response.middleware2_called).toBeTruthy()
endTest()
})
})
// see issue #485 https://github.com/middyjs/middy/issues/485
test('It will stop invoking all the onError handlers if one of them returns a promise that rejects', (endTest) => {
const handler = middy((event, context) => {
throw new Error('something bad happened')
})
const middleware1 = {
onError: (handler) => {
handler.response = { error: handler.error }
return Promise.reject(handler.error)
}
}
const middleware2 = {
onError: (handler) => {
handler.middleware2_called = true
return Promise.resolve(handler.error)
}
}
handler
.use(middleware1)
.use(middleware2)
handler({}, {}, (err, response) => {
expect(err.message).toBe('something bad happened')
expect(response).not.toBeDefined()
expect(handler.middleware2_called).not.toBeDefined()
endTest()
})
})
test('Middlewares can be stopped by calling the callback from the context', (endTest) => {

@@ -711,0 +772,0 @@ const beforeMiddleware = (handler, next) => {

4

package.json
{
"name": "@middy/core",
"version": "1.0.0-beta.10",
"version": "1.0.0-beta.11",
"description": "🛵 The stylish Node.js middleware engine for AWS Lambda (core package)",

@@ -48,3 +48,3 @@ "engines": {

},
"gitHead": "fdab45ba5ab9477dc2faddd1b812f16f56986289"
"gitHead": "34026eed4bcff4b4124b887474cc1163c6cf099c"
}
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