Repository navigation
Commit 4836ada
committed
chore: use Response.json in edge functions, drop two dead declarations
Response.json sets the JSON content type itself, so three hand-rolled
wrappers that stringified a body and spread in a Content-Type header can
delegate to it. Call sites are unchanged.
Two behavioural differences exist in principle, and neither is reachable
here:
- Response.json(undefined) throws a TypeError, where the old form produced
an empty body. Both remaining wrappers are typed `unknown`, so this was
worth checking: every one of the 12 call sites in import-source and the
3 in announcements passes an object literal, never a possibly-undefined
value.
- Response.json defers to a caller-supplied content-type, where the old form
always overrode it. No getCorsHeaders in this repo returns one.
Verified under Deno 2.9.6 that the content type is exactly "application/json"
with no charset parameter, matching the old form byte for byte.
Also deletes two declarations with no references:
- _shared/cors.ts, a wildcard Access-Control-Allow-Origin header set with
no importer, no import-map alias, and no config.toml entry. Every function
defines its own getCorsHeaders origin allowlist instead, so this file was a
misleading leftover. _shared/native-cors.test.ts is unaffected: it iterates
a hardcoded list of function names and reads ../<name>/index.ts as text, so
it never enumerates _shared or asserts on this file.
- the local Source type in ai/index.ts, never exported and never used.
Verified on main fe679fd, from a clean npm ci: docs:check, lint, typecheck,
956 unit tests, 121 edge tests, deno check on the 4 touched function
entrypoints, build, and 126 Chromium e2e tests pass.1 parent fe679fd commit 4836ada
5 files changed
Lines changed: 3 additions & 24 deletions
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 84 | + | |
88 | 85 | | |
89 | 86 | | |
90 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 30 | | |
38 | 31 | | |
39 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 26 | + | |
30 | 27 | | |
31 | 28 | | |
32 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 36 | + | |
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
| |||
0 commit comments