31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
|
|
// GET /api/uploads — list uploaded files. Returns 501 until storage is configured.
|
|
export async function GET() {
|
|
const haveR2 = process.env.R2_ACCESS_KEY_ID && process.env.R2_BUCKET && process.env.R2_ENDPOINT;
|
|
if (!haveR2) {
|
|
return NextResponse.json([], { status: 501 });
|
|
}
|
|
return NextResponse.json([]);
|
|
}
|
|
|
|
// POST /api/uploads (docs/04) — issue a presigned R2 PUT URL. Env-guarded:
|
|
// returns 501 until R2 storage is configured, and until presign generation
|
|
// is implemented — a configured-but-unimplemented state must not report
|
|
// success. Client then PUTs the file directly.
|
|
export async function POST() {
|
|
const haveR2 = process.env.R2_ACCESS_KEY_ID && process.env.R2_BUCKET && process.env.R2_ENDPOINT;
|
|
if (!haveR2) {
|
|
return NextResponse.json(
|
|
{ error: { code: "storage_not_configured", message: "Filuppladdning aktiveras när R2/Blob är kopplat" } },
|
|
{ status: 501 },
|
|
);
|
|
}
|
|
// TODO: presigned PUT generation not implemented yet — keep returning 501
|
|
// instead of a fake 200/null success shape until real R2 presign wiring exists.
|
|
return NextResponse.json(
|
|
{ error: { code: "storage_not_configured", message: "Presignerad uppladdning är inte implementerad än" } },
|
|
{ status: 501 },
|
|
);
|
|
}
|