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:
parent
4e5257481c
commit
4ef191327b
|
|
@ -91,22 +91,13 @@ export class BacklogAggregator {
|
||||||
development: process.env.NODE_ENV === "development",
|
development: process.env.NODE_ENV === "development",
|
||||||
routes: {
|
routes: {
|
||||||
// NOTE: "/" route is handled in fetch() to allow WebSocket upgrade
|
// 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": {
|
"/api/projects": {
|
||||||
GET: async () => this.handleGetProjects(),
|
GET: async () => this.handleGetProjects(),
|
||||||
},
|
},
|
||||||
"/api/tasks": {
|
"/api/tasks": {
|
||||||
GET: async (req: Request) => this.handleGetTasks(req),
|
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": {
|
"/api/tasks/update": {
|
||||||
PATCH: async (req: Request) => this.handleUpdateTask(req),
|
PATCH: async (req: Request) => this.handleUpdateTask(req),
|
||||||
},
|
},
|
||||||
|
|
@ -119,6 +110,16 @@ export class BacklogAggregator {
|
||||||
"/api/tasks/delete": {
|
"/api/tasks/delete": {
|
||||||
DELETE: async (req: Request) => this.handleDeleteTask(req),
|
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) => {
|
fetch: async (req: Request, server: Server) => {
|
||||||
const url = new URL(req.url);
|
const url = new URL(req.url);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue