MCPcopy
hub / github.com/Innei/Shiro / GET

Function GET

src/app/api/xlog/summary/route.ts:15–41  ·  view source on GitHub ↗
(req: NextRequest)

Source from the content-addressed store, hash-verified

13export const revalidate = 3600 // 1 hour
14
15export const GET = async (req: NextRequest) => {
16 const query = req.nextUrl.searchParams
17 const cid = query.get('cid')
18 const lang = query.get('lang') || 'zh'
19 if (!cid) {
20 return new NextServerResponse().status(400).end()
21 }
22
23 const queryClient = getQueryClient()
24 const res = await queryClient.fetchQuery({
25 queryKey: ['xlog-summary', cid],
26 queryFn: async () => {
27 return fetch(`https://xlog.app/api/summary?cid=${cid}&lang=${lang}`, {
28 headers: new Headers(headers),
29 })
30 .then((res) => res.json())
31 .catch(() => null)
32 },
33 })
34
35 const response = new NextServerResponse()
36 if (!res) {
37 return response.status(400).end()
38 }
39
40 return response.json({ ...res })
41}

Callers

nothing calls this directly

Calls 5

statusMethod · 0.95
jsonMethod · 0.95
getQueryClientFunction · 0.90
fetchFunction · 0.85
endMethod · 0.80

Tested by

no test coverage detected