Move Patchbay endpoints to root paths
All checks were successful
check / check (push) Successful in 35s

This commit is contained in:
matamune 2026-05-12 23:45:58 +00:00
parent 3173641827
commit 7261b48fa1
Signed by: matamune
GPG key ID: 3BB8E7D3B968A324
3 changed files with 12 additions and 10 deletions

View file

@ -6,8 +6,8 @@ Containerized Bun service for GitHub and jojo.build webhooks.
```text ```text
GET /healthz GET /healthz
POST /patchbay/jojo POST /jojo
POST /patchbay/github POST /github
``` ```
## Environment ## Environment

View file

@ -101,10 +101,10 @@ export function createHandler(config: ServerConfig): (request: Request) => Promi
if (url.pathname === "/healthz") { if (url.pathname === "/healthz") {
return textResponse("ok\n"); return textResponse("ok\n");
} }
if (url.pathname === "/patchbay/github") { if (url.pathname === "/github") {
return handleGithub(request, config, store); return handleGithub(request, config, store);
} }
if (url.pathname === "/patchbay/jojo") { if (url.pathname === "/jojo") {
return handleJojo(request, config, store); return handleJojo(request, config, store);
} }
return jsonResponse({ error: "not_found" }, { status: 404 }); return jsonResponse({ error: "not_found" }, { status: 404 });

View file

@ -31,7 +31,7 @@ describe("server", () => {
test("rejects invalid signatures", async () => { test("rejects invalid signatures", async () => {
const handler = createHandler({ githubSecret: "gh", jojoSecret: "jojo", dataDir: await mkdtemp(join(tmpdir(), "patchbay-")) }); 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", method: "POST",
headers: { "x-hub-signature-256": "sha256=bad" }, headers: { "x-hub-signature-256": "sha256=bad" },
body: "{}", body: "{}",
@ -39,16 +39,18 @@ describe("server", () => {
expect(response.status).toBe(401); 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 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: "{}" })); const legacyGitWebhooks = await handler(new Request("http://localhost/git-webhooks/jojo", { method: "POST", body: "{}" }));
expect(response.status).toBe(404); 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 () => { test("accepts jojo main pushes and queues a job", async () => {
const dataDir = await mkdtemp(join(tmpdir(), "patchbay-")); const dataDir = await mkdtemp(join(tmpdir(), "patchbay-"));
const handler = createHandler({ githubSecret: "gh", jojoSecret: "jojo", dataDir }); 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", ref: "refs/heads/main",
after: "abc123", after: "abc123",
repository: { repository: {
@ -79,7 +81,7 @@ describe("server", () => {
notifyEvents: new Set(["push"]), notifyEvents: new Set(["push"]),
}, },
}); });
const request = await signedRequest("/patchbay/jojo", "jojo", "jojo", { const request = await signedRequest("/jojo", "jojo", "jojo", {
ref: "refs/heads/main", ref: "refs/heads/main",
after: "abc123", after: "abc123",
repository: { repository: {