Theia rip-out: - Delete app/api/theia-auth/route.ts (Traefik ForwardAuth shim) - Delete app/api/projects/[projectId]/workspace/route.ts and app/api/projects/prewarm/route.ts (Cloud Run Theia provisioning) - Delete lib/cloud-run-workspace.ts and lib/coolify-workspace.ts - Strip provisionTheiaWorkspace + theiaWorkspaceUrl/theiaAppUuid/ theiaError from app/api/projects/create/route.ts response - Remove Theia callbackUrl branch in app/auth/page.tsx - Drop "Open in Theia" button + xterm/Theia PTY copy in build/page.tsx - Drop theiaWorkspaceUrl from deployment/page.tsx Project type - Strip Theia IDE line + theia-code-os from advisor + agent-chat context strings - Scrub Theia mention from lib/auth/workspace-auth.ts comment P5.1 (custom apex domains + DNS): - lib/coolify.ts + lib/opensrs.ts: nameserver normalization, OpenSRS XML auth, Cloud DNS plumbing - scripts/smoke-attach-e2e.ts: full prod GCP + sandbox OpenSRS + prod Coolify smoke covering register/zone/A/NS/PATCH/cleanup In-progress (Justine onboarding/build, MVP setup, agent telemetry): - New (justine)/stories, project (home) layouts, mvp-setup, run, tasks routes + supporting components - Project shell + sidebar + nav refactor for the Stackless palette - Agent session API hardening (sessions, events, stream, approve, retry, stop) + atlas-chat, advisor, design-surfaces refresh - New scripts/sync-db-url-from-coolify.mjs + scripts/prisma-db-push.mjs + docker-compose.local-db.yml for local Prisma workflows - lib/dev-bypass.ts, lib/chat-context-refs.ts, lib/prd-sections.ts - Misc: stories CSS, debug/prisma route, modal-theme, BuildLivePlanPanel Made-with: Cursor
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
import { authSession } from "@/lib/auth/session-server";
|
|
import { query } from '@/lib/db-postgres';
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
export async function GET(request: Request) {
|
|
try {
|
|
const session = await authSession();
|
|
if (!session?.user?.email) {
|
|
return NextResponse.json({ error: 'No authorization token provided' }, { status: 401 });
|
|
}
|
|
|
|
const rows = await query<{ data: any }>(
|
|
`SELECT data FROM fs_users WHERE data->>'email' = $1 LIMIT 1`,
|
|
[session.user.email]
|
|
);
|
|
|
|
if (rows.length > 0 && rows[0].data?.apiKey) {
|
|
return NextResponse.json({ apiKey: rows[0].data.apiKey });
|
|
}
|
|
|
|
// Generate new API key and store it
|
|
const apiKey = `vibn_${uuidv4().replace(/-/g, '')}`;
|
|
|
|
await query(
|
|
`UPDATE fs_users
|
|
SET data = data || $1::jsonb, updated_at = NOW()
|
|
WHERE data->>'email' = $2`,
|
|
[JSON.stringify({ apiKey, apiKeyCreatedAt: new Date().toISOString() }), session.user.email]
|
|
);
|
|
|
|
return NextResponse.json({ apiKey, isNew: true });
|
|
} catch (error) {
|
|
console.error('[API] Error getting/creating API key:', error);
|
|
return NextResponse.json(
|
|
{ error: 'Failed to get API key', details: error instanceof Error ? error.message : String(error) },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|