diff --git a/README.md b/README.md index b2dd230..df7a551 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,6 @@ POST /patchbay/jojo POST /patchbay/github ``` -Existing `/git-webhooks/jojo` and `/git-webhooks/github` routes remain -compatibility aliases for existing webhook registrations. - ## Environment ```text diff --git a/src/server.ts b/src/server.ts index b4c4a6b..b15b7f3 100644 --- a/src/server.ts +++ b/src/server.ts @@ -101,10 +101,10 @@ export function createHandler(config: ServerConfig): (request: Request) => Promi if (url.pathname === "/healthz") { return textResponse("ok\n"); } - if (url.pathname === "/patchbay/github" || url.pathname === "/git-webhooks/github") { + if (url.pathname === "/patchbay/github") { return handleGithub(request, config, store); } - if (url.pathname === "/patchbay/jojo" || url.pathname === "/git-webhooks/jojo") { + if (url.pathname === "/patchbay/jojo") { return handleJojo(request, config, store); } return jsonResponse({ error: "not_found" }, { status: 404 }); diff --git a/test/server.test.ts b/test/server.test.ts index bc782d9..1bdeb19 100644 --- a/test/server.test.ts +++ b/test/server.test.ts @@ -39,6 +39,12 @@ describe("server", () => { expect(response.status).toBe(401); }); + test("does not serve legacy git-webhooks routes", async () => { + const handler = createHandler({ githubSecret: "gh", jojoSecret: "jojo", dataDir: await mkdtemp(join(tmpdir(), "patchbay-")) }); + const response = await handler(new Request("http://localhost/git-webhooks/jojo", { method: "POST", body: "{}" })); + expect(response.status).toBe(404); + }); + test("accepts jojo main pushes and queues a job", async () => { const dataDir = await mkdtemp(join(tmpdir(), "patchbay-")); const handler = createHandler({ githubSecret: "gh", jojoSecret: "jojo", dataDir }); @@ -58,24 +64,6 @@ describe("server", () => { expect(await readFile(join(dataDir, "jobs.jsonl"), "utf8")).toContain("\"kind\":\"main_push\""); }); - test("keeps legacy git-webhooks routes as aliases", async () => { - const dataDir = await mkdtemp(join(tmpdir(), "patchbay-")); - const handler = createHandler({ githubSecret: "gh", jojoSecret: "jojo", dataDir }); - const request = await signedRequest("/git-webhooks/jojo", "jojo", "jojo", { - ref: "refs/heads/main", - after: "abc123", - repository: { - name: "patchbay", - full_name: "peezy-tech/patchbay", - owner: { username: "peezy-tech" }, - }, - }); - - const response = await handler(request); - expect(response.status).toBe(202); - expect(await readFile(join(dataDir, "events.jsonl"), "utf8")).toContain("\"provider\":\"jojo\""); - }); - test("continues accepting webhooks when Discord returns an error", async () => { const originalFetch = globalThis.fetch; globalThis.fetch = (async () => new Response("bad", { status: 500 })) as unknown as typeof fetch;