(req: NextRequest)
| 13 | export const revalidate = 3600 // 1 hour |
| 14 | |
| 15 | export 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 | } |
nothing calls this directly
no test coverage detected