MCPcopy
hub / github.com/callumalpass/tasknotes / getTasks

Method getTasks

src/api/TasksController.ts:49–144  ·  view source on GitHub ↗
(req: HTTPRequestLike, res: HTTPResponseLike)

Source from the content-addressed store, hash-verified

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 }

Calls 8

parseRequestUrlFunction · 0.90
hasMethod · 0.80
sendResponseMethod · 0.80
errorResponseMethod · 0.80
successResponseMethod · 0.80
getMethod · 0.65
getAllTasksMethod · 0.45
getErrorMessageMethod · 0.45

Tested by

no test coverage detected