Skip to content

Commit

Permalink
Change detection of fetch event
Browse files Browse the repository at this point in the history
  • Loading branch information
dac09 committed Dec 25, 2023
1 parent fe40f61 commit 5e0c1c2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/api/src/transforms.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Headers, Request as PonyFillRequest } from '@whatwg-node/fetch'
import { Headers } from '@whatwg-node/fetch'
import type { APIGatewayProxyEvent } from 'aws-lambda'

// This is part of the request, dreived either from a LambdaEvent or FetchAPI Request
Expand Down Expand Up @@ -50,14 +50,13 @@ export const parseFetchEventBody = async (event: Request) => {
export const isFetchApiRequest = (
event: Request | APIGatewayProxyEvent
): event is Request => {
if (
event.constructor.name === 'Request' ||
event.constructor.name === PonyFillRequest.name
) {
return true
// Arda has suggested it's better to check for a lambda event than a fetch event
// as there are some edgecases with constructor name in PonyfillRequest
if ('httpMethod' in event || 'resource' in event) {
return false
}

return false
return true
}

function getQueryStringParams(reqUrl: string) {
Expand Down

0 comments on commit 5e0c1c2

Please sign in to comment.