Skip to content

Commit

Permalink
Cleanup isFetchRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
dac09 committed Dec 22, 2023
1 parent 1a3cbd4 commit fe40f61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
20 changes: 8 additions & 12 deletions packages/api/src/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions packages/auth-providers/dbAuth/api/src/DbAuthHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) || ''

Expand Down

0 comments on commit fe40f61

Please sign in to comment.