Skip to content

Commit

Permalink
remove httpJsonBodyParser for GET requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ebisbe committed Jul 12, 2024
1 parent bff6eae commit 30c162f
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 12 deletions.
5 changes: 1 addition & 4 deletions src/functions/item/__tests__/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions src/functions/item/get.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -31,5 +30,4 @@ const getItemHandler: Handler<APIGatewayProxyEventV2> = async (event) => {

export const handler = middy()
.use(httpErrorHandler({ logger: false }))
.use(httpJsonBodyParser())
.handler(getItemHandler);
5 changes: 1 addition & 4 deletions src/functions/list/__tests__/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions src/functions/list/get.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -29,5 +28,4 @@ const getListHandler: Handler<APIGatewayProxyEventV2> = async (event) => {

export const handler = middy()
.use(httpErrorHandler({ logger: false }))
.use(httpJsonBodyParser())
.handler(getListHandler);

0 comments on commit 30c162f

Please sign in to comment.