Files
livedash-node/app/api/dashboard/config/route.ts
Kaj Kowalski cd05fc8648 fix: resolve Prettier markdown code block parsing errors
- Fix syntax errors in skills markdown files (.github/skills, .opencode/skills)
- Change typescript to tsx for code blocks with JSX
- Replace ellipsis (...) in array examples with valid syntax
- Separate CSS from TypeScript into distinct code blocks
- Convert JavaScript object examples to valid JSON in docs
- Fix enum definitions with proper comma separation
2026-01-20 21:09:29 +01:00

53 lines
1.5 KiB
TypeScript

import { type NextRequest, NextResponse } from "next/server";
import { neonAuth } from "@/lib/auth/server";
import { prisma } from "@/lib/prisma";
// MIGRATED: Removed "export const dynamic = 'force-dynamic'" - dynamic by default with Cache Components
export async function GET(_request: NextRequest) {
const { session: authSession, user: authUser } = await neonAuth();
if (!authSession || !authUser?.email) {
return NextResponse.json({ error: "Not logged in" }, { status: 401 });
}
const user = await prisma.user.findUnique({
where: { email: authUser.email },
});
if (!user || !user.companyId) {
return NextResponse.json({ error: "No user or company" }, { status: 401 });
}
// Get company data
const company = await prisma.company.findUnique({
where: { id: user.companyId },
});
return NextResponse.json({ company });
}
export async function POST(request: NextRequest) {
const { session: authSession, user: authUser } = await neonAuth();
if (!authSession || !authUser?.email) {
return NextResponse.json({ error: "Not logged in" }, { status: 401 });
}
const user = await prisma.user.findUnique({
where: { email: authUser.email },
});
if (!user || !user.companyId) {
return NextResponse.json({ error: "No user or company" }, { status: 401 });
}
const body = await request.json();
const { csvUrl } = body;
await prisma.company.update({
where: { id: user.companyId },
data: { csvUrl },
});
return NextResponse.json({ ok: true });
}