From d1dd479a37f37814d9f8692e107825364f2e3641 Mon Sep 17 00:00:00 2001 From: Naor Peled Date: Sun, 12 Nov 2023 00:23:43 +0200 Subject: [PATCH] chore: rebase --- packages/http-json-body-parser/index.d.ts | 4 ++-- .../http-json-body-parser/index.test-d.ts | 20 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/http-json-body-parser/index.d.ts b/packages/http-json-body-parser/index.d.ts index f954f4b4b..a7c1a3fe4 100644 --- a/packages/http-json-body-parser/index.d.ts +++ b/packages/http-json-body-parser/index.d.ts @@ -6,8 +6,8 @@ interface Options { disableContentTypeError?: boolean } -type VersionedApiGatewayEvent = APIGatewayEvent | APIGatewayProxyEventV2 +export type VersionedApiGatewayEvent = APIGatewayEvent | APIGatewayProxyEventV2 -declare function jsonBodyParser (options?: Options): middy.MiddlewareObj> +declare function jsonBodyParser (options?: Options): middy.MiddlewareObj export default jsonBodyParser diff --git a/packages/http-json-body-parser/index.test-d.ts b/packages/http-json-body-parser/index.test-d.ts index b384c9dba..da2a9b420 100644 --- a/packages/http-json-body-parser/index.test-d.ts +++ b/packages/http-json-body-parser/index.test-d.ts @@ -1,25 +1,24 @@ import { APIGatewayEvent, APIGatewayProxyEventV2 } from 'aws-lambda' import middy from '@middy/core' -import { expectType, expectError } from 'tsd' +import { expectType } from 'tsd' import jsonBodyParser from '.' -import { APIGatewayProxyEvent, APIGatewayProxyEventV2 } from 'aws-lambda' // use with default options let middleware = jsonBodyParser() -expectType>(middleware) +expectType>(middleware) // use with all options middleware = jsonBodyParser({ reviver: (key: string, value: any) => Boolean(value) }) -expectType>(middleware) +expectType>(middleware) -const baseEvent: Omit = { +const baseEvent: Omit = { headers: {}, - multiValueHeaders: {}, - httpMethod: 'GET', isBase64Encoded: false, + httpMethod: 'GET', path: '/', + multiValueHeaders: {}, pathParameters: null, queryStringParameters: null, multiValueQueryStringParameters: null, @@ -74,11 +73,10 @@ middifiedHandler({ ...baseEvent, // @ts-expect-error body: {} -}, {} as any) -expectType>(middleware) +}, {} as any).then(() => {}).catch(() => {}) // allow specifying the event type const apiGatewayV1Middleware = jsonBodyParser() -expectType>>(apiGatewayV1Middleware) +expectType>(apiGatewayV1Middleware) const apiGatewayV2Middleware = jsonBodyParser() -expectType>>(apiGatewayV2Middleware) +expectType>(apiGatewayV2Middleware)