Self-contained Dockerized build for end users. Run via docker compose; see README.md for setup. Source-only, no sample data or build artifacts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
28 lines
997 B
JavaScript
28 lines
997 B
JavaScript
import { NextResponse } from "next/server";
|
|
import { getAssignment, updateAssignment, deleteAssignment } from "@/lib/store";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function GET(request, { params }) {
|
|
const a = getAssignment(params.id);
|
|
if (!a) return NextResponse.json({ error: "Assignment not found." }, { status: 404 });
|
|
return NextResponse.json(a);
|
|
}
|
|
|
|
export async function PUT(request, { params }) {
|
|
try {
|
|
const body = await request.json();
|
|
const updated = updateAssignment(params.id, body);
|
|
if (!updated) return NextResponse.json({ error: "Assignment not found." }, { status: 404 });
|
|
return NextResponse.json(updated);
|
|
} catch (e) {
|
|
return NextResponse.json({ error: String(e.message || e) }, { status: 400 });
|
|
}
|
|
}
|
|
|
|
export async function DELETE(request, { params }) {
|
|
const ok = deleteAssignment(params.id);
|
|
if (!ok) return NextResponse.json({ error: "Assignment not found." }, { status: 404 });
|
|
return NextResponse.json({ ok: true });
|
|
}
|