Add deck generation and study flow improvements
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m22s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m22s
This commit is contained in:
parent
d6f3502cb1
commit
7b90409f2e
36 changed files with 8683 additions and 31 deletions
30
src/app/api/spaced-repetition-sets/route.ts
Normal file
30
src/app/api/spaced-repetition-sets/route.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { createSpacedRepetitionSetSchema } from "@/lib/validation/spacedRepetitionSchemas";
|
||||
import { spacedRepetitionErrorResponse } from "@/lib/spacedRepetitionApi";
|
||||
import * as spacedRepetitionService from "@/services/spacedRepetitionService";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const classId = new URL(request.url).searchParams.get("classId");
|
||||
if (!classId) return NextResponse.json({ error: "classId is required" }, { status: 400 });
|
||||
try {
|
||||
return NextResponse.json(await spacedRepetitionService.listSetsByClass(classId));
|
||||
} catch (error) {
|
||||
return spacedRepetitionErrorResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const parsed = createSpacedRepetitionSetSchema.safeParse(
|
||||
await request.json().catch(() => null)
|
||||
);
|
||||
if (!parsed.success) {
|
||||
return NextResponse.json({ error: "Invalid repetition set" }, { status: 400 });
|
||||
}
|
||||
try {
|
||||
return NextResponse.json(await spacedRepetitionService.createSet(parsed.data), {
|
||||
status: 201,
|
||||
});
|
||||
} catch (error) {
|
||||
return spacedRepetitionErrorResponse(error);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue