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

@middy/core

Package Overview
Dependencies
Maintainers
9
Versions
225
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-alpha.11 to 1.0.0-alpha.12

33

__tests__/index.js

@@ -432,2 +432,35 @@ const middy = require('../')

describe('A callback passed to an async handler should only be called once', () => {
const checkHandler = (handler, endTest) => {
let calls = 0
handler({}, {}, () => calls++)
setTimeout(() => {
expect(calls).toBe(1)
endTest()
}, 100)
}
test('onSuccess', (endTest) => {
const handler = middy((event, context, callback) => {
return new Promise(resolve => setTimeout(() => {
callback()
resolve()
}, 50))
})
checkHandler(handler, endTest)
})
test('onError', (endTest) => {
const handler = middy((event, context, callback) => {
return new Promise((resolve, reject) => setTimeout(() => {
const error = new Error('Async error')
callback(error)
reject(error)
}, 50))
})
checkHandler(handler, endTest)
})
})
test('A handler that returns a rejected promise will behave as an errored execution', (endTest) => {

@@ -434,0 +467,0 @@ const handler = middy((event, context) => {

9

index.js
const isPromise = require('./isPromise')
const once = require('once')

@@ -165,8 +166,8 @@ /**

const onHandlerError = (err) => {
const onHandlerError = once((err) => {
instance.response = null
return errorHandler(err)
}
})
const onHandlerSuccess = (response) => {
const onHandlerSuccess = once((response) => {
instance.response = response

@@ -178,3 +179,3 @@ runMiddlewares(afterMiddlewares, instance, (err) => {

})
}
})

@@ -181,0 +182,0 @@ const handlerReturnValue = handler.call(instance, instance.event, context, (err, response) => {

@@ -9,4 +9,17 @@ {

"integrity": "sha512-p6pNNZ/VERiboy/S9ygkmimqZC082RzDE9SXcTUbsKRW5p0kbq+Yrt8IVlf49CM/F45nRPdCCPJtGembGHYtWg=="
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"requires": {
"wrappy": "1"
}
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
}
}
}
{
"name": "@middy/core",
"version": "1.0.0-alpha.11",
"version": "1.0.0-alpha.12",
"description": "🛵 The stylish Node.js middleware engine for AWS Lambda (core package)",

@@ -39,4 +39,5 @@ "engines": {

"dependencies": {
"@types/aws-lambda": "^8.10.3"
"@types/aws-lambda": "^8.10.3",
"once": "^1.4.0"
}
}
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