mirror of
https://github.com/joeseesun/wechat-radar.git
synced 2026-09-10 09:58:30 +09:00
Publish updated WeChat Radar
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { backfillMessageLinks } from '@/lib/message-links';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
export const maxDuration = 300;
|
||||
|
||||
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
const body = (await req.json().catch(() => ({}))) as {
|
||||
since?: string;
|
||||
until?: string;
|
||||
};
|
||||
|
||||
if (body.since && !DATE_RE.test(body.since)) {
|
||||
return NextResponse.json({ ok: false, error: 'invalid since' }, { status: 400 });
|
||||
}
|
||||
if (body.until && !DATE_RE.test(body.until)) {
|
||||
return NextResponse.json({ ok: false, error: 'invalid until' }, { status: 400 });
|
||||
}
|
||||
|
||||
const result = backfillMessageLinks(body.since, body.until);
|
||||
return NextResponse.json({ ok: true, ...result });
|
||||
}
|
||||
Reference in New Issue
Block a user