Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(http-json-body-parser): parameter typings #1119

Closed
wants to merge 1 commit into from

Conversation

GentileFulvio
Copy link

An attemp to fix the following bug #1116 .
This is my first time submitting a PR in this repo so let me know if I interpreted anything wrong

@willfarrell
Copy link
Member

willfarrell commented Oct 30, 2023

Thanks for putting the PR together. I think this change has already been made in our v5 branch (see below). Does this meet your needs? We're just waiting on AWS to release the nodejs-20 runtime before releasing it. There is an alpha you can get now though.

import middy from '@middy/core'
import { APIGatewayEvent, APIGatewayProxyEventV2 } from 'aws-lambda'
import { JsonValue } from 'type-fest'

interface Options {
  reviver?: (key: string, value: any) => any
  disableContentTypeError?: boolean
}

type VersionedApiGatewayEvent = APIGatewayEvent | APIGatewayProxyEventV2

export type Event<APIGatewayEventType extends VersionedApiGatewayEvent = VersionedApiGatewayEvent> = Omit<APIGatewayEventType, 'body'> & {
  /**
   * The body of the HTTP request.
   */
  body: JsonValue
}

declare function jsonBodyParser<APIGatewayEventType extends VersionedApiGatewayEvent = VersionedApiGatewayEvent> (options?: Options): middy.MiddlewareObj<Event<APIGatewayEventType>>

export default jsonBodyParser

@willfarrell
Copy link
Member

Close because I believe this has already been done in v5. Please re-open if you think I'm mistaken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants