Initial release of Moniki paid services site and CMS (v1.0.0).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alexey Novikov
2026-09-16 13:10:25 +03:00
co-authored by Cursor
commit 8abd8d06dd
263 changed files with 24973 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
import { AUTH_COOKIE, CMS_URL } from "@/lib/api";
import { cookies } from "next/headers";
import { NextResponse } from "next/server";
export async function GET() {
const store = await cookies();
const token = store.get(AUTH_COOKIE)?.value;
if (!token) return NextResponse.json({ user: null }, { status: 401 });
if (token === "demo-token") {
return NextResponse.json({
user: { id: "demo", email: "patient@example.com", name: "Пациент", phone: "+7" },
});
}
try {
const res = await fetch(`${CMS_URL}/api/users/me`, {
headers: { Authorization: `Bearer ${token}` },
cache: "no-store",
});
const data = await res.json();
return NextResponse.json(data, { status: res.status });
} catch {
return NextResponse.json({
user: { id: "demo", email: "patient@example.com", name: "Пациент" },
});
}
}
export async function PATCH(request: Request) {
const store = await cookies();
const token = store.get(AUTH_COOKIE)?.value;
if (!token) return NextResponse.json({ message: "Unauthorized" }, { status: 401 });
const body = await request.json();
if (token === "demo-token") {
return NextResponse.json({ user: { id: "demo", ...body } });
}
try {
const res = await fetch(`${CMS_URL}/api/users/me`, {
method: "PATCH",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
const data = await res.json();
return NextResponse.json(data, { status: res.status });
} catch {
return NextResponse.json({ user: { id: "demo", ...body } });
}
}