(req: HTTPRequestLike, res: HTTPResponseLike)
| 47 | |
| 48 | @Get("/api/tasks") |
| 49 | async getTasks(req: HTTPRequestLike, res: HTTPResponseLike): Promise<void> { |
| 50 | try { |
| 51 | const params = parseRequestUrl(req).searchParams; |
| 52 | |
| 53 | // Check if user is trying to use filtering parameters |
| 54 | const filterParams = [ |
| 55 | "status", |
| 56 | "priority", |
| 57 | "project", |
| 58 | "context", |
| 59 | "tag", |
| 60 | "overdue", |
| 61 | "completed", |
| 62 | "archived", |
| 63 | "due_before", |
| 64 | "due_after", |
| 65 | "sort", |
| 66 | ]; |
| 67 | const hasFilters = filterParams.some((param) => params.has(param)); |
| 68 | |
| 69 | if (hasFilters) { |
| 70 | // Recommend using the more powerful query endpoint |
| 71 | this.sendResponse( |
| 72 | res, |
| 73 | 400, |
| 74 | this.errorResponse( |
| 75 | "For filtering tasks, please use POST /api/tasks/query which supports advanced filtering capabilities. " + |
| 76 | "GET /api/tasks is for basic listing only. See API documentation for details." |
| 77 | ) |
| 78 | ); |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | const allTasks = await this.cacheManager.getAllTasks(); |
| 83 | |
| 84 | // Basic pagination only |
| 85 | let offset = 0; |
| 86 | let limit = 50; // Reduced default for basic listing |
| 87 | |
| 88 | const offsetParam = params.get("offset"); |
| 89 | if (offsetParam) { |
| 90 | offset = parseInt(offsetParam, 10); |
| 91 | if (isNaN(offset) || offset < 0) { |
| 92 | offset = 0; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | const limitParam = params.get("limit"); |
| 97 | if (limitParam) { |
| 98 | limit = parseInt(limitParam, 10); |
| 99 | if (isNaN(limit) || limit < 1) { |
| 100 | limit = 50; |
| 101 | } |
| 102 | // Cap the limit |
| 103 | if (limit > 200) { |
| 104 | limit = 200; |
| 105 | } |
| 106 | } |
no test coverage detected