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

Function buildEntryPoints

src/ui-server/api/entrypoints.ts:166–208  ·  view source on GitHub ↗
(cg: CodeGraph, query: URLSearchParams)

Source from the content-addressed store, hash-verified

164// =============================================================================
165
166export function buildEntryPoints(cg: CodeGraph, query: URLSearchParams): WireEntryPoints {
167 const started = Date.now();
168 const limit = intParam(query, 'limit', { min: 1, max: 50, default: DEFAULT_LIMIT });
169 const routeLimit = intParam(query, 'routes', {
170 min: 3,
171 max: MAX_ROUTE_LIMIT,
172 default: DEFAULT_ROUTE_LIMIT,
173 });
174
175 const stats = cg.getStats();
176 // JSON rather than a joined string: a project root can contain any character
177 // a separator might have picked, and this key is compared for equality only.
178 const key = JSON.stringify([
179 cg.getProjectRoot(),
180 cg.getLastIndexedAt() ?? 0,
181 stats.edgeCount,
182 stats.fileCount,
183 limit,
184 routeLimit,
185 ]);
186 const hit = cache.get(key);
187 if (hit) {
188 // Re-stamp rather than mutate: the body is shared with the next caller.
189 return { ...hit, timing: { elapsedMs: Date.now() - started, cached: true } };
190 }
191
192 const payload: WireEntryPoints = {
193 frameworks: cg.getDetectedFrameworks(),
194 routes: routeEntries(cg, routeLimit),
195 files: executableFiles(cg, limit),
196 tests: testFiles(cg, limit),
197 hubs: hubs(cg, limit),
198 index: { lastIndexedAt: cg.getLastIndexedAt() ?? null, files: stats.fileCount },
199 timing: { elapsedMs: Date.now() - started, cached: false },
200 };
201
202 if (cache.size >= CACHE_LIMIT) {
203 const oldest = cache.keys().next();
204 if (!oldest.done) cache.delete(oldest.value);
205 }
206 cache.set(key, payload);
207 return payload;
208}
209
210/**
211 * The routing manifest, trimmed to a starting-points list.

Callers 2

handlerFunction · 0.90

Calls 13

intParamFunction · 0.90
routeEntriesFunction · 0.85
executableFilesFunction · 0.85
testFilesFunction · 0.85
hubsFunction · 0.85
nextMethod · 0.80
getProjectRootMethod · 0.65
getMethod · 0.65
deleteMethod · 0.65
getStatsMethod · 0.45
getLastIndexedAtMethod · 0.45
getDetectedFrameworksMethod · 0.45

Tested by

no test coverage detected