alpha01 filetti: web app, crossword service and tor batch
This commit is contained in:
18
webapp/app/api/crosswords/[id]/route.ts
Normal file
18
webapp/app/api/crosswords/[id]/route.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
const RUNTIME_DIR = join(process.cwd(), ".runtime-crosswords");
|
||||
|
||||
export async function GET(
|
||||
_request: Request,
|
||||
context: { params: Promise<{ id: string }> },
|
||||
) {
|
||||
try {
|
||||
const { id } = await context.params;
|
||||
const source = await readFile(join(RUNTIME_DIR, `${id}.json`), "utf-8");
|
||||
return NextResponse.json(JSON.parse(source));
|
||||
} catch {
|
||||
return NextResponse.json({ status: "not_found" }, { status: 404 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user