Skip to content
Merged

7.1.3 #1581

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6a453cc
docs: fix website build
willfarrell Feb 24, 2026
17e9c77
Merge branch 'main' into develop
willfarrell Feb 24, 2026
bf5bbb9
chore: improve types
willfarrell Feb 25, 2026
b892b86
feat: add in missin gtypes
willfarrell Feb 25, 2026
0941336
fix: http status codes
willfarrell Feb 25, 2026
abefbac
feat: update in missing types
willfarrell Feb 25, 2026
310ef8b
fix: improve tests and types
willfarrell Feb 25, 2026
c8e9fd2
chore: more type clean up
willfarrell Feb 25, 2026
8e63f35
test: improve testing name patterns
willfarrell Feb 25, 2026
6c01568
chore: clean up test naming
willfarrell Feb 25, 2026
f7da36a
chore: clean up tests naming
willfarrell Feb 25, 2026
336dbaa
test: add in more type tests
willfarrell Feb 25, 2026
99abc48
test: bump testing up to 100%
willfarrell Feb 25, 2026
a527008
chore: remove gitHead
willfarrell Feb 25, 2026
6a59f7d
chore: more clean up
willfarrell Feb 25, 2026
221c03b
fix: small perf boost
willfarrell Feb 25, 2026
e424b5d
docs: typo
willfarrell Feb 25, 2026
bad733c
chore: clean up
willfarrell Feb 25, 2026
ce763cd
chore: pref improvements
willfarrell Feb 26, 2026
fde400f
chore: lint
willfarrell Feb 26, 2026
c172783
chore: add in missing dep
willfarrell Feb 26, 2026
fa5d737
fix: small perf improvement
willfarrell Feb 26, 2026
9d97cc2
fix: small perf improvements
willfarrell Feb 26, 2026
2374031
test: fix undefined
willfarrell Feb 26, 2026
7787f7a
chore: small perf improvements
willfarrell Feb 26, 2026
7c9cd1f
docs: improve code coverage
willfarrell Feb 26, 2026
f73de7c
chore: small perf improvements
willfarrell Feb 26, 2026
d910713
fix: validator regression
willfarrell Mar 3, 2026
6894646
docs: update to match current types
willfarrell Mar 3, 2026
701dc93
chore: dep update
willfarrell Mar 3, 2026
dc8305a
Merge branch 'main' into develop
willfarrell Mar 3, 2026
bc2e9ee
chore: version bump
willfarrell Mar 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: small perf improvement
Signed-off-by: will Farrell <willfarrell@proton.me>
  • Loading branch information
willfarrell committed Feb 26, 2026
commit fa5d737d2c4f5d6966e017ab0dbdb57634e82774
14 changes: 7 additions & 7 deletions packages/core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface PluginObject {
}

export interface Request<
TEvent = any,
TEvent = unknown,
TResult = any,
TErr = Error,
TContext extends LambdaContext | LambdaContextDurable = LambdaContext,
Expand All @@ -46,7 +46,7 @@ export interface Request<
}

declare type MiddlewareFn<
TEvent = any,
TEvent = unknown,
TResult = any,
TErr = Error,
TContext extends LambdaContext | LambdaContextDurable = LambdaContext,
Expand Down Expand Up @@ -91,7 +91,7 @@ type MiddyInputPromiseHandler<
> = (event: TEvent, context: TContext) => Promise<TResult>;

export interface MiddyfiedHandler<
TEvent = any,
TEvent = unknown,
TResult = any,
TErr = Error,
TContext extends LambdaContext | LambdaContextDurable = LambdaContext,
Expand Down Expand Up @@ -122,7 +122,7 @@ export interface MiddyfiedHandler<
}

declare type AttachMiddlewareFn<
TEvent = any,
TEvent = unknown,
TResult = any,
TErr = Error,
TContext extends LambdaContext | LambdaContextDurable = LambdaContext,
Expand All @@ -132,7 +132,7 @@ declare type AttachMiddlewareFn<
) => MiddyfiedHandler<TEvent, TResult, TErr, TContext, TInternal>;

declare type AttachMiddlewareObj<
TEvent = any,
TEvent = unknown,
TResult = any,
TErr = Error,
TContext extends LambdaContext | LambdaContextDurable = LambdaContext,
Expand All @@ -142,7 +142,7 @@ declare type AttachMiddlewareObj<
) => MiddyfiedHandler<TEvent, TResult, TErr, TContext, TInternal>;

declare type UseFn<
TEvent = any,
TEvent = unknown,
TResult = any,
TErr = Error,
TContext extends LambdaContext | LambdaContextDurable = LambdaContext,
Expand Down Expand Up @@ -187,7 +187,7 @@ declare type MiddlewareHandler<
THandler extends LambdaHandler<any, any>,
TContext extends LambdaContext | LambdaContextDurable = LambdaContext,
TResult = any,
TEvent = any,
TEvent = unknown,
> =
THandler extends LambdaHandler<TEvent, TResult> // always true
? MiddyInputHandler<TEvent, TResult, TContext>
Expand Down
2 changes: 1 addition & 1 deletion packages/do-not-wait-for-empty-event-loop/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const defaults = {
const doNotWaitForEmptyEventLoopMiddleware = (opts = {}) => {
const options = { ...defaults, ...opts };

const doNotWaitForEmptyEventLoop = async (request) => {
const doNotWaitForEmptyEventLoop = (request) => {
if (isExecutionModeDurable(request.context)) {
request.context.lambdaContext.callbackWaitsForEmptyEventLoop = false;
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/error-logger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const errorLoggerMiddleware = (opts = {}) => {
let { logger } = { ...defaults, ...opts };
if (typeof logger !== "function") logger = null;

const errorLoggerMiddlewareOnError = async (request) => {
const errorLoggerMiddlewareOnError = (request) => {
logger(request);
};
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/event-normalizer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const defaults = {

const eventNormalizerMiddleware = (opts = {}) => {
const options = { ...defaults, ...opts };
const eventNormalizerMiddlewareBefore = async (request) => {
const eventNormalizerMiddlewareBefore = (request) => {
parseEvent(request.event, options);
};
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/http-content-negotiation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const defaults = {
const httpContentNegotiationMiddleware = (opts = {}) => {
const options = { ...defaults, ...opts };

const httpContentNegotiationMiddlewareBefore = async (request) => {
const httpContentNegotiationMiddlewareBefore = (request) => {
const { event, context } = request;
if (!event.headers) return;
if (options.parseCharsets) {
Expand Down
6 changes: 3 additions & 3 deletions packages/http-cors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ const httpCorsMiddleware = (opts = {}) => {
}
};

const httpCorsMiddlewareBefore = async (request) => {
const httpCorsMiddlewareBefore = (request) => {
if (options.disableBeforePreflightResponse) return;

const method = getVersionHttpMethod[request.event.version ?? "1.0"]?.(
Expand Down Expand Up @@ -240,9 +240,9 @@ const httpCorsMiddleware = (opts = {}) => {
}
};

const httpCorsMiddlewareAfter = async (request) => {
const httpCorsMiddlewareAfter = (request) => {
normalizeHttpResponse(request);
const headers = structuredClone(request.response.headers);
const headers = { ...request.response.headers };
modifyHeaders(headers, options, request);
request.response.headers = headers;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/http-error-handler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const defaults = {
const httpErrorHandlerMiddleware = (opts = {}) => {
const options = { ...defaults, ...opts };

const httpErrorHandlerMiddlewareOnError = async (request) => {
const httpErrorHandlerMiddlewareOnError = (request) => {
if (typeof request.response !== "undefined") return;
if (typeof options.logger === "function") {
options.logger(request.error);
Expand Down
2 changes: 1 addition & 1 deletion packages/http-event-normalizer/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2017 - 2026 will Farrell, Luciano Mammino, and Middy contributors.
// SPDX-License-Identifier: MIT
const httpEventNormalizerMiddleware = () => {
const httpEventNormalizerMiddlewareBefore = async (request) => {
const httpEventNormalizerMiddlewareBefore = (request) => {
const { event } = request;

const version = pickVersion(event);
Expand Down
2 changes: 1 addition & 1 deletion packages/http-header-normalizer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const httpHeaderNormalizerMiddleware = (opts = {}) => {
: options.defaultHeaders[key].split(",");
}

const httpHeaderNormalizerMiddlewareBefore = async (request) => {
const httpHeaderNormalizerMiddlewareBefore = (request) => {
if (request.event.headers) {
const headers = { ...defaultHeaders };

Expand Down
2 changes: 1 addition & 1 deletion packages/http-json-body-parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const defaults = {

const httpJsonBodyParserMiddleware = (opts = {}) => {
const options = { ...defaults, ...opts };
const httpJsonBodyParserMiddlewareBefore = async (request) => {
const httpJsonBodyParserMiddlewareBefore = (request) => {
const { headers, body } = request.event;
const contentType = headers?.["content-type"] ?? headers?.["Content-Type"];

Expand Down
4 changes: 2 additions & 2 deletions packages/http-multipart-body-parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import BusBoy from "@fastify/busboy";
import { createError } from "@middy/util";

const mimePattern =
/^multipart\/form-data; boundary=[a-zA-Z0-9-]{1,70}(; ?[cC]harset=[\w-]+)?$/;
/^multipart\/form-data; boundary=[a-zA-Z0-9-]{1,70}(; ?charset=[\w-]+)?$/i;
const fieldnamePattern = /(.+)\[(.*)]$/;

const defaults = {
Expand All @@ -18,7 +18,7 @@ const defaults = {
const httpMultipartBodyParserMiddleware = (opts = {}) => {
const options = { ...defaults, ...opts };

const httpMultipartBodyParserMiddlewareBefore = async (request) => {
const httpMultipartBodyParserMiddlewareBefore = (request) => {
const { headers, body } = request.event;

const contentType = headers?.["content-type"] ?? headers?.["Content-Type"];
Expand Down
2 changes: 1 addition & 1 deletion packages/http-partial-response/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const httpPartialResponseMiddleware = (opts = {}) => {
const options = { ...defaults, ...opts };
const { filteringKeyName } = options;

const httpPartialResponseMiddlewareAfter = async (request) => {
const httpPartialResponseMiddlewareAfter = (request) => {
const fields = request.event?.queryStringParameters?.[filteringKeyName];
if (!fields) return;

Expand Down
2 changes: 1 addition & 1 deletion packages/http-response-serializer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const defaults = {

const httpResponseSerializerMiddleware = (opts = {}) => {
const { serializers, defaultContentType } = { ...defaults, ...opts };
const httpResponseSerializerMiddlewareAfter = async (request) => {
const httpResponseSerializerMiddlewareAfter = (request) => {
normalizeHttpResponse(request);

// skip serialization when Content-Type or content-type is already set
Expand Down
2 changes: 1 addition & 1 deletion packages/http-security-headers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ helmet.xssProtection = (headers, config) => {
const httpSecurityHeadersMiddleware = (opts = {}) => {
const options = { ...defaults, ...opts };

const httpSecurityHeadersMiddlewareAfter = async (request) => {
const httpSecurityHeadersMiddlewareAfter = (request) => {
normalizeHttpResponse(request);

for (const key of Object.keys(helmet)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/http-urlencode-body-parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// SPDX-License-Identifier: MIT
import { createError, decodeBody } from "@middy/util";

const mimePattern = /^application\/x-www-form-urlencoded(;.*)?$/;
const mimePattern = /^application\/x-www-form-urlencoded(;.*)?$/i;
const defaults = {
disableContentTypeCheck: false,
disableContentTypeError: false,
};
const httpUrlencodeBodyParserMiddleware = (opts = {}) => {
const options = { ...defaults, ...opts };

const httpUrlencodeBodyParserMiddlewareBefore = async (request) => {
const httpUrlencodeBodyParserMiddlewareBefore = (request) => {
const { headers, body } = request.event;

const contentType = headers?.["content-type"] ?? headers?.["Content-Type"];
Expand Down
2 changes: 1 addition & 1 deletion packages/http-urlencode-path-parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: MIT
import { createError } from "@middy/util";

const httpUrlencodePathParserMiddlewareBefore = async (request) => {
const httpUrlencodePathParserMiddlewareBefore = (request) => {
if (!request.event.pathParameters) return;
for (const key of Object.keys(request.event.pathParameters)) {
try {
Expand Down
4 changes: 2 additions & 2 deletions packages/input-output-logger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ const inputOutputLoggerMiddleware = (opts = {}) => {
}
};

const inputOutputLoggerMiddlewareBefore = async (request) => {
const inputOutputLoggerMiddlewareBefore = (request) => {
omitAndLog("event", request);
};
const inputOutputLoggerMiddlewareAfter = async (request) => {
const inputOutputLoggerMiddlewareAfter = (request) => {
// Check for Node.js stream
if (
request.response?._readableState ??
Expand Down
2 changes: 1 addition & 1 deletion packages/sqs-partial-batch-failure/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const defaults = {
const sqsPartialBatchFailureMiddleware = (opts = {}) => {
const { logger } = { ...defaults, ...opts };

const sqsPartialBatchFailureMiddlewareAfter = async (request) => {
const sqsPartialBatchFailureMiddlewareAfter = (request) => {
const {
event: { Records },
response,
Expand Down
2 changes: 1 addition & 1 deletion packages/ws-json-body-parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const defaults = {

const wsJsonBodyParserMiddleware = (opts = {}) => {
const options = { ...defaults, ...opts };
const wsJsonBodyParserMiddlewareBefore = async (request) => {
const wsJsonBodyParserMiddlewareBefore = (request) => {
const { body } = request.event;
if (typeof body === "undefined") {
throw createError(422, "Invalid or malformed JSON was provided", {
Expand Down