MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / readScriptRoutes

Function readScriptRoutes

graph-ui/src/provider/route-reader.ts:124–151  ·  view source on GitHub ↗

Method calls and decorators, which is how JavaScript, TypeScript and Python register.

(source: string)

Source from the content-addressed store, hash-verified

122
123/** Method calls and decorators, which is how JavaScript, TypeScript and Python register. */
124function readScriptRoutes(source: string): SourceRoute[] {
125 const routes: SourceRoute[] = [];
126 for (const match of source.matchAll(VERB_CALL_PATTERN)) {
127 routes.push({
128 method: match[1].toUpperCase(),
129 path: match[3],
130 line: lineAt(source, match.index ?? 0)
131 });
132 }
133 for (const match of source.matchAll(DECORATOR_ROUTE_PATTERN)) {
134 const line = lineAt(source, match.index ?? 0);
135 const methods = DECORATOR_METHODS_PATTERN.exec(match[3] ?? '');
136 if (!methods) {
137 // A decorator with no `methods=` accepts GET in every framework that
138 // spells it this way, but this reader is not the place to encode
139 // that: the honest answer is that the registration names no verb.
140 routes.push({ path: match[2], line });
141 continue;
142 }
143 for (const verb of methods[1].split(',')) {
144 const cleaned = verb.replace(/['"\s]/g, '').toUpperCase();
145 if (cleaned.length > 0) {
146 routes.push({ method: cleaned, path: match[2], line });
147 }
148 }
149 }
150 return routes;
151}
152
153/**
154 * Annotations, which is how Spring and its relatives register.

Callers 1

readRoutesFunction · 0.85

Calls 2

lineAtFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected