From 7261b48fa110abb00e6ae4aa2852822b7a66b55e Mon Sep 17 00:00:00 2001 From: matamune Date: Tue, 12 May 2026 23:45:58 +0000 Subject: [PATCH] Move Patchbay endpoints to root paths --- README.md | 4 ++-- src/server.ts | 4 ++-- test/server.test.ts | 14 ++++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index df7a551..651edfd 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Containerized Bun service for GitHub and jojo.build webhooks. ```text GET /healthz -POST /patchbay/jojo -POST /patchbay/github +POST /jojo +POST /github ``` ## Environment diff --git a/src/server.ts b/src/server.ts index b15b7f3..6526518 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") { + if (url.pathname === "/github") { return handleGithub(request, config, store); } - if (url.pathname === "/patchbay/jojo") { + if (url.pathname === "/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 1bdeb19..55b6060 100644 --- a/test/server.test.ts +++ b/test/server.test.ts @@ -31,7 +31,7 @@ describe("server", () => { test("rejects invalid signatures", async () => { const handler = createHandler({ githubSecret: "gh", jojoSecret: "jojo", dataDir: await mkdtemp(join(tmpdir(), "patchbay-")) }); - const response = await handler(new Request("http://localhost/patchbay/github", { + const response = await handler(new Request("http://localhost/github", { method: "POST", headers: { "x-hub-signature-256": "sha256=bad" }, body: "{}", @@ -39,16 +39,18 @@ describe("server", () => { expect(response.status).toBe(401); }); - test("does not serve legacy git-webhooks routes", async () => { + test("does not serve old path-prefixed 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); + const legacyGitWebhooks = await handler(new Request("http://localhost/git-webhooks/jojo", { method: "POST", body: "{}" })); + const legacyPatchbay = await handler(new Request("http://localhost/patchbay/jojo", { method: "POST", body: "{}" })); + expect(legacyGitWebhooks.status).toBe(404); + expect(legacyPatchbay.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 }); - const request = await signedRequest("/patchbay/jojo", "jojo", "jojo", { + const request = await signedRequest("/jojo", "jojo", "jojo", { ref: "refs/heads/main", after: "abc123", repository: { @@ -79,7 +81,7 @@ describe("server", () => { notifyEvents: new Set(["push"]), }, }); - const request = await signedRequest("/patchbay/jojo", "jojo", "jojo", { + const request = await signedRequest("/jojo", "jojo", "jojo", { ref: "refs/heads/main", after: "abc123", repository: {