Skip to content

Commit 38b9547

Browse files
authored
Well known headers in typescript file (#3014)
Need this for #3011 For some weird reason it's no longer working with latest rolldown. Todo: align the generator tool <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Migrated headers data storage from JSON to TypeScript module format for improved maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent b3ada6e commit 38b9547

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

express-zod-api/src/documentation-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { ezRawBrand } from "./raw-schema.ts";
4545
import { FirstPartyKind } from "./schema-walker.ts";
4646
import { Security } from "./security.ts";
4747
import { ezUploadBrand } from "./upload-schema.ts";
48-
import wellKnownHeaders from "./well-known-headers.json" with { type: "json" };
48+
import wellKnownHeaders from "./well-known-headers.ts";
4949

5050
interface ReqResCommons {
5151
makeRef: (

express-zod-api/src/well-known-headers.json renamed to express-zod-api/src/well-known-headers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[
1+
export default [
22
"a-im",
33
"accept",
44
"accept-additions",
@@ -201,5 +201,5 @@
201201
"want-repr-digest",
202202
"warning",
203203
"x-content-type-options",
204-
"x-frame-options"
205-
]
204+
"x-frame-options",
205+
];

tools/headers.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { execSync } from "node:child_process";
22
import { writeFile } from "node:fs/promises";
3+
import { format } from "prettier";
34

45
/**
56
* @link https://chatgpt.com/c/6795dae3-8a10-800e-96af-fd0d01579f39
@@ -208,7 +209,7 @@ const responseOnlyHeaders = {
208209
},
209210
};
210211

211-
const dest = "express-zod-api/src/well-known-headers.json";
212+
const dest = "express-zod-api/src/well-known-headers.ts";
212213

213214
let mtime: Date | undefined;
214215
try {
@@ -252,4 +253,6 @@ const headers = lines
252253

253254
console.debug("CRC:", headers.length);
254255

255-
await writeFile(dest, JSON.stringify(headers, undefined, 2), "utf-8");
256+
const json = JSON.stringify(headers, undefined, 2);
257+
const tsCode = await format(`export default ${json};`, { filepath: dest });
258+
await writeFile(dest, tsCode, "utf-8");

0 commit comments

Comments
 (0)