MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / pypiApiPath

Function pypiApiPath

website/api/pypi.ts:3–15  ·  view source on GitHub ↗
(reqUrl: string | undefined)

Source from the content-addressed store, hash-verified

1// api/pypi.ts — proxy to pypistats.org for download counters
2
3function pypiApiPath(reqUrl: string | undefined): string {
4 if (!reqUrl) return "/packages/codegraphcontext/recent";
5
6 try {
7 const pathname = reqUrl.startsWith("http")
8 ? new URL(reqUrl).pathname
9 : reqUrl.split("?")[0];
10 const stripped = pathname.replace(/^\/api\/pypi/, "") || "/packages/codegraphcontext/recent";
11 return stripped.startsWith("/") ? stripped : `/${stripped}`;
12 } catch {
13 return "/packages/codegraphcontext/recent";
14 }
15}
16
17export default async function handler(req: any, res: any) {
18 res.setHeader("Access-Control-Allow-Origin", "*");

Callers 1

handlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected