MCPcopy
hub / github.com/CaliCastle/cali.so / GET

Function GET

app/api/reactions/route.ts:19–37  ·  view source on GitHub ↗
(req: NextRequest)

Source from the content-addressed store, hash-verified

17})
18
19export async function GET(req: NextRequest) {
20 const { searchParams } = new URL(req.url)
21 const id = searchParams.get('id')
22 if (!id) return new Response('Missing id', { status: 400 })
23
24 const value = await redis.get<number[]>(`reactions:${id}`)
25 if (!value) {
26 await redis.set(getKey(id), [0, 0, 0, 0])
27 }
28
29 const { success } = await ratelimit.limit(getKey(id) + `_${req.ip ?? ''}`)
30 if (!success) {
31 return new Response('Too Many Requests', {
32 status: 429,
33 })
34 }
35
36 return NextResponse.json(value ?? [0, 0, 0, 0])
37}
38
39export async function PATCH(req: NextRequest) {
40 const { searchParams } = new URL(req.url)

Callers

nothing calls this directly

Calls 1

getKeyFunction · 0.70

Tested by

no test coverage detected