MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / route

Method route

src/api/APIRouter.ts:65–92  ·  view source on GitHub ↗
(req: HTTPRequestLike, res: HTTPResponseLike)

Source from the content-addressed store, hash-verified

63 }
64
65 async route(req: HTTPRequestLike, res: HTTPResponseLike): Promise<boolean> {
66 const pathname = parseRequestUrl(req).pathname;
67 const method = req.method as HTTPMethod;
68
69 for (const route of this.routes) {
70 if (route.method === method) {
71 const match = pathname.match(route.regex);
72 if (match) {
73 const params: Record<string, string> = {};
74
75 // Extract route parameters
76 for (let i = 0; i < route.paramNames.length; i++) {
77 const paramName = route.paramNames[i];
78 const paramValue = match[i + 1];
79 if (paramValue) {
80 params[paramName] = decodeURIComponent(paramValue);
81 }
82 }
83
84 // Call the handler
85 await route.handler(req, res, params);
86 return true;
87 }
88 }
89 }
90
91 return false;
92 }
93
94 /**
95 * Register a controller using decorator-based routes

Callers 1

handleRequestMethod · 0.80

Calls 1

parseRequestUrlFunction · 0.90

Tested by

no test coverage detected