feat: API Keys via Umgebungsvariablen konfigurierbar

- Neuer getApiKey() Helper: prüft zuerst ENV-Vars, dann DB
- Alle Job-Routes nutzen getApiKey() statt direktem DB-Lookup
- Credentials-Status berücksichtigt ENV-Vars (Sidebar-Haken)
- .env.local.example: Platzhalter für alle 4 API Keys

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Timo Uttenweiler
2026-03-20 13:58:41 +01:00
parent 39760b20a9
commit ea93d674a2
9 changed files with 54 additions and 49 deletions

View File

@@ -1,6 +1,6 @@
import { NextRequest, NextResponse } from "next/server";
import { prisma } from "@/lib/db";
import { decrypt } from "@/lib/utils/encryption";
import { getApiKey } from "@/lib/utils/apiKey";
import { createOrder, getOrderStatus, triggerExport, downloadOrderCSV } from "@/lib/services/vayne";
export async function POST(req: NextRequest) {
@@ -12,11 +12,8 @@ export async function POST(req: NextRequest) {
return NextResponse.json({ error: "Invalid Sales Navigator URL" }, { status: 400 });
}
const cred = await prisma.apiCredential.findUnique({ where: { service: "vayne" } });
if (!cred?.value) {
return NextResponse.json({ error: "Vayne API token not configured" }, { status: 400 });
}
const apiToken = decrypt(cred.value);
const apiToken = await getApiKey("vayne");
if (!apiToken) return NextResponse.json({ error: "Vayne API token not configured" }, { status: 400 });
const job = await prisma.job.create({
data: {