a1c5fecd83
- Switch Prisma schema from SQLite to PostgreSQL - Add netlify.toml for Netlify deployment config - Add @netlify/plugin-nextjs for serverless Next.js - Remove Docker build files (Dockerfile, docker-compose, start.sh) - Remove auto-healer and scripts directories - Update next.config.ts (remove standalone output) - Database: falah_mobile_v1 on Contabo Postgres
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { prisma } from "@/lib/prisma";
|
|
import { requireAuth } from "@/lib/auth";
|
|
|
|
export async function GET(req: NextRequest) {
|
|
const jwtPayload = await requireAuth(req);
|
|
if (!jwtPayload) {
|
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
}
|
|
|
|
const user = await prisma.user.findUnique({
|
|
where: { id: jwtPayload.userId },
|
|
});
|
|
|
|
if (!user) {
|
|
return NextResponse.json({ error: "User not found" }, { status: 404 });
|
|
}
|
|
|
|
return NextResponse.json({
|
|
user: {
|
|
id: user.id,
|
|
email: user.email,
|
|
name: user.name,
|
|
isPremium: user.isPremium,
|
|
isPro: user.isPro,
|
|
flhBalance: user.flhBalance,
|
|
flhPurchased: (user as any).flhPurchased ?? 0,
|
|
dailyMsgCount: user.dailyMsgCount,
|
|
experienceLevel: user.experienceLevel,
|
|
madhab: user.madhab,
|
|
coachPersona: user.coachPersona,
|
|
preferredName: user.preferredName,
|
|
coachingGoals: user.coachingGoals,
|
|
trialEndsAt: user.trialEndsAt,
|
|
createdAt: user.createdAt,
|
|
},
|
|
});
|
|
}
|