mirror of
https://github.com/joeseesun/wechat-radar.git
synced 2026-09-12 03:38:31 +09:00
Initial open source release
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
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 });
|
||||
}
|
||||
Reference in New Issue
Block a user