feat: implement archiving functionality for counters and update related logic
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import db from '@/lib/db';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
type Params = { params: Promise<{ id: string }> };
|
||||
|
||||
export async function POST(_req: Request, { params }: Params) {
|
||||
const { id } = await params;
|
||||
const existing = db.prepare('SELECT * FROM counters WHERE id = ?').get(Number(id));
|
||||
if (!existing) return NextResponse.json({ error: 'Not found' }, { status: 404 });
|
||||
const updated = db.prepare('UPDATE counters SET archived_at = ? WHERE id = ? RETURNING *').get(Date.now(), Number(id));
|
||||
return NextResponse.json(updated);
|
||||
}
|
||||
Reference in New Issue
Block a user