mirror of
https://github.com/joeseesun/wechat-radar.git
synced 2026-09-10 14:28:31 +09:00
19 lines
634 B
TypeScript
19 lines
634 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { getTopicDetail } from '@/lib/topics';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
export async function GET(
|
|
_req: NextRequest,
|
|
ctx: { params: Promise<{ id: string }> },
|
|
) {
|
|
const { id } = await ctx.params;
|
|
const numId = Number(id);
|
|
if (!Number.isInteger(numId) || numId <= 0) {
|
|
return NextResponse.json({ ok: false, error: 'invalid id' }, { status: 400 });
|
|
}
|
|
const detail = await getTopicDetail(numId);
|
|
if (!detail) return NextResponse.json({ ok: false, error: 'not found' }, { status: 404 });
|
|
return NextResponse.json({ ok: true, ...detail });
|
|
}
|