rebuild app as turbopack-first single-stack with internal api and openclaw tasks
This commit is contained in:
29
frontend/app/api/watchlist/[id]/route.ts
Normal file
29
frontend/app/api/watchlist/[id]/route.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { jsonError } from '@/lib/server/http';
|
||||
import { withStore } from '@/lib/server/store';
|
||||
|
||||
type Context = {
|
||||
params: Promise<{ id: string }>;
|
||||
};
|
||||
|
||||
export async function DELETE(_request: Request, context: Context) {
|
||||
const { id } = await context.params;
|
||||
const numericId = Number(id);
|
||||
|
||||
if (!Number.isInteger(numericId) || numericId <= 0) {
|
||||
return jsonError('Invalid watchlist id', 400);
|
||||
}
|
||||
|
||||
let removed = false;
|
||||
|
||||
await withStore((store) => {
|
||||
const next = store.watchlist.filter((item) => item.id !== numericId);
|
||||
removed = next.length !== store.watchlist.length;
|
||||
store.watchlist = next;
|
||||
});
|
||||
|
||||
if (!removed) {
|
||||
return jsonError('Watchlist item not found', 404);
|
||||
}
|
||||
|
||||
return Response.json({ success: true });
|
||||
}
|
||||
Reference in New Issue
Block a user