Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
fix: add coercion on http handler
Browse files Browse the repository at this point in the history
  • Loading branch information
pevisscher committed Dec 11, 2023
1 parent 1824972 commit f85528f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@skyleague/event-horizon-dev",
"version": "4.0.4",
"version": "4.0.11",
"description": "The accompanying development package for @skyleague/event-horizon.",
"repository": {
"type": "git",
Expand Down
7 changes: 7 additions & 0 deletions src/lib/event-horizon/http/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ export function httpEvent<
event.raw.isBase64Encoded ? Buffer.from(b.toString()).toString('base64') : b
) as typeof event.raw.body
}

// force coercion
http.schema.body?.is(event.body)
http.schema.headers?.is(event.headers)
http.schema.query?.is(event.query)
http.schema.path?.is(event.path)

event.raw.headers ??= (event.headers as typeof event.raw.headers) ?? {}

Check warning on line 52 in src/lib/event-horizon/http/http.ts

View workflow job for this annotation

GitHub Actions / typescript / check

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined

Check warning on line 52 in src/lib/event-horizon/http/http.ts

View workflow job for this annotation

GitHub Actions / typescript / check

Unnecessary conditional, value is `never`
event.raw.queryStringParameters ??= (event.query as typeof event.raw.queryStringParameters) ?? {}

Check warning on line 53 in src/lib/event-horizon/http/http.ts

View workflow job for this annotation

GitHub Actions / typescript / check

Unnecessary conditional, left-hand side of `??` operator is always `null` or `undefined`
const rawEvent = event.raw
Expand Down

0 comments on commit f85528f

Please sign in to comment.