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
86 lines
2.7 KiB
TypeScript
86 lines
2.7 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
import { authSession } from "@/lib/auth/session-server";
|
|
import { query } from '@/lib/db-postgres';
|
|
|
|
export async function GET(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ projectId: string }> }
|
|
) {
|
|
try {
|
|
const { projectId } = await params;
|
|
|
|
const session = await authSession();
|
|
if (!session?.user?.email) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
}
|
|
|
|
const rows = await query<{ id: string; data: any }>(`
|
|
SELECT p.id, p.data
|
|
FROM fs_projects p
|
|
JOIN fs_users u ON u.id = p.user_id
|
|
WHERE p.id = $1 AND u.data->>'email' = $2
|
|
LIMIT 1
|
|
`, [projectId, session.user.email]);
|
|
|
|
if (rows.length === 0) {
|
|
return NextResponse.json({ error: 'Project not found' }, { status: 404 });
|
|
}
|
|
|
|
return NextResponse.json({ success: true, project: { id: rows[0].id, ...rows[0].data } });
|
|
} catch (error) {
|
|
console.error('[GET /api/projects/:id] Error:', error);
|
|
return NextResponse.json(
|
|
{ error: 'Failed to fetch project', details: error instanceof Error ? error.message : String(error) },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|
|
|
|
export async function PATCH(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ projectId: string }> }
|
|
) {
|
|
try {
|
|
const { projectId } = await params;
|
|
const body = await request.json();
|
|
|
|
const session = await authSession();
|
|
if (!session?.user?.email) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
}
|
|
|
|
// Fetch current data (verify ownership)
|
|
const rows = await query<{ id: string; data: any }>(`
|
|
SELECT p.id, p.data
|
|
FROM fs_projects p
|
|
JOIN fs_users u ON u.id = p.user_id
|
|
WHERE p.id = $1 AND u.data->>'email' = $2
|
|
LIMIT 1
|
|
`, [projectId, session.user.email]);
|
|
|
|
if (rows.length === 0) {
|
|
return NextResponse.json({ error: 'Project not found' }, { status: 404 });
|
|
}
|
|
|
|
const current = rows[0].data || {};
|
|
const updated = { ...current };
|
|
const allowedFields = ['vision', 'description', 'name', 'githubRepo', 'productVision', 'productName'];
|
|
for (const field of allowedFields) {
|
|
if (body[field] !== undefined) updated[field] = body[field];
|
|
}
|
|
updated.updatedAt = new Date().toISOString();
|
|
|
|
await query(`
|
|
UPDATE fs_projects SET data = $1::jsonb WHERE id = $2
|
|
`, [JSON.stringify(updated), projectId]);
|
|
|
|
return NextResponse.json({ success: true, message: 'Project updated successfully' });
|
|
} catch (error) {
|
|
console.error('[PATCH /api/projects/:id] Error:', error);
|
|
return NextResponse.json(
|
|
{ error: 'Failed to update project', details: error instanceof Error ? error.message : String(error) },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|