Skip to content

Commit fe40f61

Browse files
committed
Cleanup isFetchRequest
1 parent 1a3cbd4 commit fe40f61

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

packages/api/src/transforms.ts

+8-12
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,17 @@ export const parseFetchEventBody = async (event: Request) => {
4747
return body ? JSON.parse(body) : undefined
4848
}
4949

50-
// @TODO
51-
// @TODO
52-
// @TODO
53-
// THis is in a hacked state. Need to figure out why instanceof isn't working in middleware
54-
export const isFetchApiRequest = (event: any): event is Request => {
55-
if (event instanceof Request || event instanceof PonyFillRequest) {
50+
export const isFetchApiRequest = (
51+
event: Request | APIGatewayProxyEvent
52+
): event is Request => {
53+
if (
54+
event.constructor.name === 'Request' ||
55+
event.constructor.name === PonyFillRequest.name
56+
) {
5657
return true
5758
}
5859

59-
if (event.httpMethod || event.queryStringParameters) {
60-
return false
61-
}
62-
63-
// @TODO I dont know why instance of Request is not working in middleware
64-
return true
60+
return false
6561
}
6662

6763
function getQueryStringParams(reqUrl: string) {

packages/auth-providers/dbAuth/api/src/DbAuthHandler.ts

-4
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,6 @@ export class DbAuthHandler<
393393
this.options = options
394394
this.event = event
395395
this.httpMethod = isFetchApiRequest(event) ? event.method : event.httpMethod
396-
console.log(
397-
`👉 \n ~ file: DbAuthHandler.ts:396 ~ isFetchApiRequest(event):`,
398-
isFetchApiRequest(event)
399-
)
400396

401397
this.cookie = extractCookie(event) || ''
402398

0 commit comments

Comments
 (0)