diff --git a/src/aggregator/index.ts b/src/aggregator/index.ts index 89a7333..5deb268 100644 --- a/src/aggregator/index.ts +++ b/src/aggregator/index.ts @@ -91,22 +91,13 @@ export class BacklogAggregator { development: process.env.NODE_ENV === "development", routes: { // NOTE: "/" route is handled in fetch() to allow WebSocket upgrade + // IMPORTANT: Static routes must come BEFORE parameterized routes to avoid `:project` matching literal paths "/api/projects": { GET: async () => this.handleGetProjects(), }, "/api/tasks": { GET: async (req: Request) => this.handleGetTasks(req), }, - "/api/tasks/:project/:id": { - GET: async (req: Request & { params: { project: string; id: string } }) => - this.handleGetTask(req.params.project, req.params.id), - }, - "/api/statuses": { - GET: async () => this.handleGetStatuses(), - }, - "/api/health": { - GET: async () => Response.json({ status: "ok", projects: this.projects.size, tasks: this.tasks.size }), - }, "/api/tasks/update": { PATCH: async (req: Request) => this.handleUpdateTask(req), }, @@ -119,6 +110,16 @@ export class BacklogAggregator { "/api/tasks/delete": { DELETE: async (req: Request) => this.handleDeleteTask(req), }, + "/api/tasks/:project/:id": { + GET: async (req: Request & { params: { project: string; id: string } }) => + this.handleGetTask(req.params.project, req.params.id), + }, + "/api/statuses": { + GET: async () => this.handleGetStatuses(), + }, + "/api/health": { + GET: async () => Response.json({ status: "ok", projects: this.projects.size, tasks: this.tasks.size }), + }, }, fetch: async (req: Request, server: Server) => { const url = new URL(req.url);