Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions functions/api/[[path]].ts

This file was deleted.

22 changes: 0 additions & 22 deletions functions/api/redirects.ts

This file was deleted.

93 changes: 0 additions & 93 deletions functions/schema.ts

This file was deleted.

9 changes: 0 additions & 9 deletions functions/tsconfig.json

This file was deleted.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
"astro": "npx astro",
"build": "npx astro build",
"postbuild": "npm run build:worker",
"build:worker": "npx wrangler types -c wrangler-workers.toml --experimental-include-runtime && npx wrangler pages functions build --outdir worker/functions",
"check": "npm run check:functions && npm run check:astro",
"build:worker": "npx wrangler types -c wrangler-workers.toml --experimental-include-runtime",
"check": "npm run check:astro && npm run check:worker",
"check:astro": "npm run sync && astro check",
"check:functions": "npx tsc --noEmit -p ./functions/tsconfig.json",
"check:worker": "npx tsc --noEmit -p ./worker/tsconfig.json",
"check:worker": "npm run build:worker && npx tsc --noEmit -p ./worker/tsconfig.json",
"dev": "npx astro dev",
"format": "npm run format:core && npm run format:data",
"format:core": "npx prettier --write \"**/*.{js,jsx,ts,tsx,mjs,css}\"",
Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/openapi.json

This file was deleted.

40 changes: 0 additions & 40 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { fetchMock, SELF } from "cloudflare:test";
import { describe, it, expect, beforeAll, afterEach } from "vitest";
import openAPISchema from "./fixtures/openapi.json";
import puppeteer, { Browser, HTTPRequest } from "@cloudflare/puppeteer";
import { inject } from "vitest";

Expand Down Expand Up @@ -83,43 +82,4 @@ describe("Cloudflare Docs", () => {
const fullTitle = await textSelector?.evaluate((el) => el.textContent);
expect(fullTitle).toContain("Cloudflare Docs");
});

it("responds with API schema at `/schema`", async () => {
fetchMock
.get("https://raw.githubusercontent.com")
.intercept({ path: "/cloudflare/api-schemas/main/openapi.json" })
.reply(200, JSON.stringify(openAPISchema));

const request = new Request("http://fakehost/schema");
const response = await SELF.fetch(request);
expect(response.headers.get("Content-Type")).toBe("application/json");
const data = (await response.json()) as any;
expect(Object.keys(data)).toMatchInlineSnapshot(`
[
"components",
"info",
"openapi",
"paths",
"security",
"servers",
]
`);
});

it("responds with API docs files at `/api/*`", async () => {
const mockContents = `const some = 'js';`;

fetchMock
.get("https://cloudflare-api-docs-frontend.pages.dev")
.intercept({
path: (p) => {
return p === "//static/js/file.js";
},
})
.reply(200, mockContents);

const request = new Request("http://fakehost/api/static/js/file.js");
const response = await SELF.fetch(request);
expect(await response.text()).toEqual(mockContents);
});
});
7 changes: 0 additions & 7 deletions worker/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { WorkerEntrypoint } from "cloudflare:workers";
import { generateRedirectsEvaluator } from "redirects-in-workers";
import redirectsFileContents from "../dist/_redirects";
import functions from "./functions";

const redirectsEvaluator = generateRedirectsEvaluator(redirectsFileContents);

Expand Down Expand Up @@ -51,12 +50,6 @@ export default class extends WorkerEntrypoint<Env> {
error,
);
}

try {
return await functions.fetch(request, this.env, this.ctx);
} catch (error) {
console.error("Could not evaluate functions", error);
}
} catch (error) {
console.error("Unknown error", error);
}
Expand Down
Loading