From fe40f6120188169838b8407da64f2af929bce693 Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Fri, 22 Dec 2023 18:09:11 +0700 Subject: [PATCH] Cleanup isFetchRequest --- packages/api/src/transforms.ts | 20 ++++++++----------- .../dbAuth/api/src/DbAuthHandler.ts | 4 ---- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/packages/api/src/transforms.ts b/packages/api/src/transforms.ts index 4400ead69202..7ce6baa412e2 100644 --- a/packages/api/src/transforms.ts +++ b/packages/api/src/transforms.ts @@ -47,21 +47,17 @@ export const parseFetchEventBody = async (event: Request) => { return body ? JSON.parse(body) : undefined } -// @TODO -// @TODO -// @TODO -// THis is in a hacked state. Need to figure out why instanceof isn't working in middleware -export const isFetchApiRequest = (event: any): event is Request => { - if (event instanceof Request || event instanceof PonyFillRequest) { +export const isFetchApiRequest = ( + event: Request | APIGatewayProxyEvent +): event is Request => { + if ( + event.constructor.name === 'Request' || + event.constructor.name === PonyFillRequest.name + ) { return true } - if (event.httpMethod || event.queryStringParameters) { - return false - } - - // @TODO I dont know why instance of Request is not working in middleware - return true + return false } function getQueryStringParams(reqUrl: string) { diff --git a/packages/auth-providers/dbAuth/api/src/DbAuthHandler.ts b/packages/auth-providers/dbAuth/api/src/DbAuthHandler.ts index 844b0673b49e..42bb02cb8d93 100644 --- a/packages/auth-providers/dbAuth/api/src/DbAuthHandler.ts +++ b/packages/auth-providers/dbAuth/api/src/DbAuthHandler.ts @@ -393,10 +393,6 @@ export class DbAuthHandler< this.options = options this.event = event this.httpMethod = isFetchApiRequest(event) ? event.method : event.httpMethod - console.log( - `👉 \n ~ file: DbAuthHandler.ts:396 ~ isFetchApiRequest(event):`, - isFetchApiRequest(event) - ) this.cookie = extractCookie(event) || ''