fix: route ordering in aggregator for /api/tasks/* endpoints

Same fix as server - static routes (/api/tasks/update, /api/tasks/create,
etc.) must be defined before parameterized routes (/api/tasks/:project/:id)
to prevent Bun's router from matching the parameter route first.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2025-12-04 04:55:13 -08:00
parent 4e5257481c
commit 4ef191327b
1 changed files with 11 additions and 10 deletions

View File

@ -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);