feat(portal+admin): complete tail pages (files, integrationer, admin jobs, admin customers) + uploads/db-grant API stubs
All nav targets now exist on PortalShell; env-guarded actions degrade gracefully. tsc 0, build green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
// POST /api/connections/db-grant (docs/04, docs/08) — accept a customer-created
|
||||
// read-only, time-boxed DB role. Connection string is stored ENCRYPTED (AES-GCM
|
||||
// via GRANT_ENC_KEY), never in plaintext, and deleted after the job. Env-guarded.
|
||||
export async function POST(req: NextRequest) {
|
||||
const body = await req.json().catch(() => ({}));
|
||||
if (!process.env.GRANT_ENC_KEY) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: {
|
||||
code: "grants_not_configured",
|
||||
message: "DB-åtkomst aktiveras när GRANT_ENC_KEY är satt. Skapa en read-only, tidsbegränsad roll åt oss — vi efterfrågar aldrig admin.",
|
||||
},
|
||||
},
|
||||
{ status: 501 },
|
||||
);
|
||||
}
|
||||
// With GRANT_ENC_KEY: validate read-only, AES-GCM encrypt conn_string, store, audit.
|
||||
return NextResponse.json({ grant_id: crypto.randomUUID(), status: "pending", order_id: body?.order_id ?? null }, { status: 201 });
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
// POST /api/uploads (docs/04) — issue a presigned R2 PUT URL. Env-guarded:
|
||||
// returns 501 until R2 storage is configured. Client then PUTs the file directly.
|
||||
export async function POST(req: NextRequest) {
|
||||
const body = await req.json().catch(() => ({}));
|
||||
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 },
|
||||
);
|
||||
}
|
||||
// With R2 configured: build a presigned PUT (S3-compatible) and return it.
|
||||
return NextResponse.json({ file_id: crypto.randomUUID(), put_url: null, name: body?.name ?? null });
|
||||
}
|
||||
Reference in New Issue
Block a user