Skip to content

Commit 4e4c781

Browse files
committed
fix: add root API response
1 parent 9379d6e commit 4e4c781

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

apps/commandboard-api/src/contract.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ afterAll(async () => {
2222
});
2323

2424
describe("CommandBoard API contracts", () => {
25+
it("exposes root API index", async () => {
26+
const response = await fetch(`${baseUrl}/`);
27+
const body = await response.json() as { ok: boolean; service: string; endpoints: string[] };
28+
29+
expect(response.status).toBe(200);
30+
expect(body).toMatchObject({ ok: true, service: "commandboard-api" });
31+
expect(body.endpoints).toEqual(expect.arrayContaining(["/health", "/api/boards", "/api/plugins"]));
32+
});
33+
2534
it("exposes health contract", async () => {
2635
const response = await fetch(`${baseUrl}/health`);
2736
const body = await response.json() as { ok: boolean; service: string };

apps/commandboard-api/src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ export function createCommandBoardServer() {
5454
async function route(request: IncomingMessage, response: ServerResponse) {
5555
const url = new URL(request.url ?? "/", "http://localhost");
5656

57+
if (request.method === "GET" && url.pathname === "/") {
58+
json(response, 200, {
59+
ok: true,
60+
service: "commandboard-api",
61+
endpoints: ["/health", "/api/boards", "/api/tasks", "/api/plugins", "/api/schemas"]
62+
});
63+
return;
64+
}
65+
5766
if (request.method === "GET" && url.pathname === "/health") {
5867
json(response, 200, { ok: true, service: "commandboard-api" });
5968
return;

0 commit comments

Comments
 (0)