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

@middy/core

Package Overview
Dependencies
Maintainers
3
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 5.0.2 to 5.0.3

25

index.js

@@ -1,2 +0,2 @@

/* global awslambda */ import { Readable } from 'node:stream';
import { Readable } from 'node:stream';
import { pipeline } from 'node:stream/promises';

@@ -16,6 +16,5 @@ import { setTimeout } from 'node:timers/promises';

},
streamifyResponse: false // Deprecate need for this when AWS provides a flag for when it's looking for it
streamifyResponse: false
};
const middy = (lambdaHandler = defaultLambdaHandler, plugin = {})=>{
// Allow base handler to be set using .handler()
if (typeof lambdaHandler !== 'function') {

@@ -56,5 +55,5 @@ plugin = lambdaHandler;

handlerBody = handlerResponse.body ?? '';
delete handlerResponse.body;
responseStream = awslambda.HttpResponseStream.from(responseStream, handlerResponse);
}
// Source @datastream/core (MIT)
let handlerStream;

@@ -65,4 +64,3 @@ if (handlerBody._readableState) {

function* iterator(input) {
const size = 16384 // 16 * 1024 // Node.js default
;
const size = 16384;
let position = 0;

@@ -99,3 +97,2 @@ const length = input.length;

};
// Inline Middlewares
middy.before = (beforeMiddleware)=>{

@@ -121,7 +118,5 @@ beforeMiddlewares.push(beforeMiddleware);

let timeoutAbort;
const timeoutEarly = plugin.timeoutEarly && request.context.getRemainingTimeInMillis // disable when AWS context missing (tests, containers)
;
const timeoutEarly = plugin.timeoutEarly && request.context.getRemainingTimeInMillis;
try {
await runMiddlewares(request, beforeMiddlewares, plugin);
// Check if before stack hasn't exit early
if (typeof request.response === 'undefined') {

@@ -142,4 +137,3 @@ plugin.beforeHandler?.();

]);
timeoutAbort?.abort() // lambdaHandler may not be a promise
;
timeoutAbort?.abort();
plugin.afterHandler?.();

@@ -149,5 +143,3 @@ await runMiddlewares(request, afterMiddlewares, plugin);

} catch (e) {
timeoutAbort?.abort() // timeout should be aborted on errors
;
// Reset response changes made by after stack before error thrown
timeoutAbort?.abort();
request.response = undefined;

@@ -158,3 +150,2 @@ request.error = e;

} catch (e) {
// Save error that wasn't handled
e.originalError = request.error;

@@ -164,3 +155,2 @@ request.error = e;

}
// Catch if onError stack hasn't handled the error
if (typeof request.response === 'undefined') throw request.error;

@@ -177,3 +167,2 @@ } finally{

plugin.afterMiddleware?.(nextMiddleware.name);
// short circuit chaining and respond early
if (typeof res !== 'undefined') {

@@ -180,0 +169,0 @@ request.response = res;

{
"name": "@middy/core",
"version": "5.0.2",
"version": "5.0.3",
"description": "🛵 The stylish Node.js middleware engine for AWS Lambda (core package)",

@@ -62,3 +62,3 @@ "type": "module",

},
"gitHead": "6d17e155237022f2a0abd095ac7cd99ebfc7fc71",
"gitHead": "87660575a7ac2b52e4153c407a4c63c9449dcd0d",
"dependencies": {

@@ -65,0 +65,0 @@ "@datastream/core": "0.0.35"

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