From 30c162f75dea396621005cd67f47eb0393ec0e23 Mon Sep 17 00:00:00 2001 From: Enric Bisbe Gil Date: Fri, 12 Jul 2024 09:44:50 +0200 Subject: [PATCH] remove httpJsonBodyParser for GET requests --- src/functions/item/__tests__/get.test.js | 5 +---- src/functions/item/get.ts | 2 -- src/functions/list/__tests__/get.test.js | 5 +---- src/functions/list/get.ts | 2 -- 4 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/functions/item/__tests__/get.test.js b/src/functions/item/__tests__/get.test.js index 7a6a607..cdf724a 100644 --- a/src/functions/item/__tests__/get.test.js +++ b/src/functions/item/__tests__/get.test.js @@ -5,10 +5,7 @@ import { handler } from "../get"; describe("GET Item", () => { it("requires path parameter ID", async () => { - const response = await handler({ - headers: { "Content-Type": "application/json" }, - body: null, - }); + const response = await handler({}); expect(response).toStrictEqual({ statusCode: 400, diff --git a/src/functions/item/get.ts b/src/functions/item/get.ts index 0224816..1fd347e 100644 --- a/src/functions/item/get.ts +++ b/src/functions/item/get.ts @@ -1,6 +1,5 @@ import middy from "@middy/core"; import httpErrorHandler from "@middy/http-error-handler"; -import httpJsonBodyParser from "@middy/http-json-body-parser"; import { APIGatewayProxyEventV2, Handler } from "aws-lambda"; import { z } from "zod"; @@ -31,5 +30,4 @@ const getItemHandler: Handler = async (event) => { export const handler = middy() .use(httpErrorHandler({ logger: false })) - .use(httpJsonBodyParser()) .handler(getItemHandler); diff --git a/src/functions/list/__tests__/get.test.js b/src/functions/list/__tests__/get.test.js index 0817e25..558fdeb 100644 --- a/src/functions/list/__tests__/get.test.js +++ b/src/functions/list/__tests__/get.test.js @@ -5,10 +5,7 @@ import { handler } from "../get"; describe("GET List", () => { it("requires path parameter ID", async () => { - const response = await handler({ - headers: { "Content-Type": "application/json" }, - body: null, - }); + const response = await handler({}); expect(response).toStrictEqual({ statusCode: 400, diff --git a/src/functions/list/get.ts b/src/functions/list/get.ts index 4539933..0981851 100644 --- a/src/functions/list/get.ts +++ b/src/functions/list/get.ts @@ -1,6 +1,5 @@ import middy from "@middy/core"; import httpErrorHandler from "@middy/http-error-handler"; -import httpJsonBodyParser from "@middy/http-json-body-parser"; import { APIGatewayProxyEventV2, Handler } from "aws-lambda"; import { z } from "zod"; @@ -29,5 +28,4 @@ const getListHandler: Handler = async (event) => { export const handler = middy() .use(httpErrorHandler({ logger: false })) - .use(httpJsonBodyParser()) .handler(getListHandler);