Skip to content

Commit 564a1c8

Browse files
authored
[Docs Site] Remove old API docs functions (#18789)
* [Docs Site] Remove old API docs functions * remove tests * remove fixtures * fixup package.json scripts * remove fixture import
1 parent fe18bb1 commit 564a1c8

File tree

8 files changed

+3
-223
lines changed

8 files changed

+3
-223
lines changed

functions/api/[[path]].ts

Lines changed: 0 additions & 47 deletions
This file was deleted.

functions/api/redirects.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

functions/schema.ts

Lines changed: 0 additions & 93 deletions
This file was deleted.

functions/tsconfig.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
"astro": "npx astro",
77
"build": "npx astro build",
88
"postbuild": "npm run build:worker",
9-
"build:worker": "npx wrangler types -c wrangler-workers.toml --experimental-include-runtime && npx wrangler pages functions build --outdir worker/functions",
10-
"check": "npm run check:functions && npm run check:astro",
9+
"build:worker": "npx wrangler types -c wrangler-workers.toml --experimental-include-runtime",
10+
"check": "npm run check:astro && npm run check:worker",
1111
"check:astro": "npm run sync && astro check",
12-
"check:functions": "npx tsc --noEmit -p ./functions/tsconfig.json",
13-
"check:worker": "npx tsc --noEmit -p ./worker/tsconfig.json",
12+
"check:worker": "npm run build:worker && npx tsc --noEmit -p ./worker/tsconfig.json",
1413
"dev": "npx astro dev",
1514
"format": "npm run format:core && npm run format:data",
1615
"format:core": "npx prettier --write \"**/*.{js,jsx,ts,tsx,mjs,css}\"",

tests/fixtures/openapi.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/index.test.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { fetchMock, SELF } from "cloudflare:test";
22
import { describe, it, expect, beforeAll, afterEach } from "vitest";
3-
import openAPISchema from "./fixtures/openapi.json";
43
import puppeteer, { Browser, HTTPRequest } from "@cloudflare/puppeteer";
54
import { inject } from "vitest";
65

@@ -83,43 +82,4 @@ describe("Cloudflare Docs", () => {
8382
const fullTitle = await textSelector?.evaluate((el) => el.textContent);
8483
expect(fullTitle).toContain("Cloudflare Docs");
8584
});
86-
87-
it("responds with API schema at `/schema`", async () => {
88-
fetchMock
89-
.get("https://raw.githubusercontent.com")
90-
.intercept({ path: "/cloudflare/api-schemas/main/openapi.json" })
91-
.reply(200, JSON.stringify(openAPISchema));
92-
93-
const request = new Request("http://fakehost/schema");
94-
const response = await SELF.fetch(request);
95-
expect(response.headers.get("Content-Type")).toBe("application/json");
96-
const data = (await response.json()) as any;
97-
expect(Object.keys(data)).toMatchInlineSnapshot(`
98-
[
99-
"components",
100-
"info",
101-
"openapi",
102-
"paths",
103-
"security",
104-
"servers",
105-
]
106-
`);
107-
});
108-
109-
it("responds with API docs files at `/api/*`", async () => {
110-
const mockContents = `const some = 'js';`;
111-
112-
fetchMock
113-
.get("https://cloudflare-api-docs-frontend.pages.dev")
114-
.intercept({
115-
path: (p) => {
116-
return p === "//static/js/file.js";
117-
},
118-
})
119-
.reply(200, mockContents);
120-
121-
const request = new Request("http://fakehost/api/static/js/file.js");
122-
const response = await SELF.fetch(request);
123-
expect(await response.text()).toEqual(mockContents);
124-
});
12585
});

worker/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { WorkerEntrypoint } from "cloudflare:workers";
22
import { generateRedirectsEvaluator } from "redirects-in-workers";
33
import redirectsFileContents from "../dist/_redirects";
4-
import functions from "./functions";
54

65
const redirectsEvaluator = generateRedirectsEvaluator(redirectsFileContents);
76

@@ -51,12 +50,6 @@ export default class extends WorkerEntrypoint<Env> {
5150
error,
5251
);
5352
}
54-
55-
try {
56-
return await functions.fetch(request, this.env, this.ctx);
57-
} catch (error) {
58-
console.error("Could not evaluate functions", error);
59-
}
6053
} catch (error) {
6154
console.error("Unknown error", error);
6255
}

0 commit comments

Comments
 (0)