MCPcopy Create free account
hub / github.com/arctic-cli/interface / GET

Function GET

packages/web/app/api/track/install/route.ts:17–55  ·  view source on GitHub ↗
(request: NextRequest)

Source from the content-addressed store, hash-verified

15const VALID_ARCH = ["x64", "arm64", "x86", "baseline", "musl"]
16
17export async function GET(request: NextRequest) {
18 try {
19 const ip = request.headers.get("x-forwarded-for") || request.headers.get("x-real-ip") || "unknown"
20
21 const { success } = await ratelimit.limit(ip)
22 if (!success) {
23 return new Response(null, { status: 429 })
24 }
25
26 const { searchParams } = new URL(request.url)
27 const os = searchParams.get("os")
28 const arch = searchParams.get("arch")
29
30 if (!os || !arch) {
31 return new Response(null, { status: 204 })
32 }
33
34 if (!VALID_OS.includes(os) || !VALID_ARCH.includes(arch)) {
35 return new Response(null, { status: 204 })
36 }
37
38 const date = new Date().toISOString().split("T")[0]
39
40 const dailyKey = `installs:daily:${date}:${os}:${arch}`
41
42 await redis
43 .pipeline()
44 .incr("installs:total")
45 .incr(`installs:os:${os}`)
46 .incr(`installs:arch:${arch}`)
47 .incr(dailyKey)
48 .exec()
49
50 return new Response(null, { status: 204 })
51 } catch (error) {
52 console.error("Track install error:", error)
53 return new Response(null, { status: 204 })
54 }
55}

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected