MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / fastEndpointConstantRoutes

Function fastEndpointConstantRoutes

src/resolution/frameworks/csharp.ts:381–403  ·  view source on GitHub ↗

* A FastEndpoints route named by a constant (`Post(CreateContributorRequest.Route)`) * gets the constant's value: `public const string Route = "/Contributors";` in * that class, wherever it is declared. Idempotent — the qualified name keeps the * expression.

(context: ResolutionContext)

Source from the content-addressed store, hash-verified

379 * expression.
380 */
381function fastEndpointConstantRoutes(context: ResolutionContext): Node[] {
382 const updates: Node[] = [];
383 for (const route of context.getNodesByKind('route')) {
384 if (route.language !== 'csharp') continue;
385 const q = /::fastendpoint:([A-Z]+):const:([A-Za-z_]\w*)\.([A-Za-z_]\w*)$/.exec(route.qualifiedName);
386 if (!q) continue;
387 const [, method, owner, field] = q;
388 let value: string | null = null;
389 for (const decl of context.getNodesByName(owner!)) {
390 if (decl.language !== 'csharp' || (decl.kind !== 'class' && decl.kind !== 'struct')) continue;
391 const text = context.readFile(decl.filePath) ?? '';
392 const m = new RegExp(`\\b(?:const\\s+string|static\\s+readonly\\s+string|static\\s+string)\\s+${field}\\s*=\\s*"([^"]+)"`).exec(text);
393 if (m) {
394 value = m[1]!;
395 break;
396 }
397 }
398 if (!value) continue;
399 const name = `${method} ${joinCsPath('', value)}`;
400 if (name !== route.name) updates.push({ ...route, name });
401 }
402 return updates;
403}
404
405/**
406 * The endpoint-group prefix convention, read once from the app: the

Callers 1

postExtractFunction · 0.85

Calls 6

joinCsPathFunction · 0.85
pushMethod · 0.80
getNodesByKindMethod · 0.65
execMethod · 0.65
getNodesByNameMethod · 0.65
readFileMethod · 0.65

Tested by

no test coverage detected