- Remove .prettierrc (dead config, Biome replaces Prettier) - Rename lighthouserc.json to lighthouserc.cjs with module.exports for ESM compat - Add logger.warn to empty catch blocks in auth, register, site-settings, prisma-cache, redis, security, rate-limit - Unify ActionResult type: action-helper.ts uses 'ok' consistent with safe-action-shared.ts - Add noUnusedLocals + noUnusedParameters to tsconfig + fix 25 pre-existing unused vars - Replace barrel export src/types/index.ts with direct @/types/common imports - Make trustHost conditional (development only) in auth.ts - Add pre-flight URL validation to update-Nitrov3.sh to catch image.library.url misconfigurations - Improve NITRO_IMAGE_LIBRARY_URL content validation in pre-flight & post-compute checks
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { headers } from "next/headers";
|
|
import { redirect } from "next/navigation";
|
|
import { auth } from "@/lib/auth";
|
|
import { issueSsoTicket } from "@/lib/auth/sso-ticket";
|
|
import { cached } from "@/lib/cache";
|
|
import { resolveHotelName } from "@/lib/hotel-name";
|
|
import { prisma } from "@/lib/prisma";
|
|
import { siteSettings } from "@/lib/services/site-settings";
|
|
import { ClientView } from "./client-view";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export default async function ClientPage() {
|
|
const session = await auth();
|
|
if (!session?.user?.id) redirect("/login");
|
|
|
|
const userId = Number(session.user.id);
|
|
|
|
const [hotelName, clientUrl] = await Promise.all([
|
|
resolveHotelName(),
|
|
siteSettings.get("nitro_client_url", ""),
|
|
]);
|
|
|
|
const ip = (await headers()).get("x-real-client-ip") ?? "0.0.0.0";
|
|
const ticket = await issueSsoTicket(prisma, userId, hotelName, ip);
|
|
|
|
const onlineCount = await cached("online_count", 10_000, () =>
|
|
prisma.user.count({ where: { online: "1" } }),
|
|
).catch(() => 0);
|
|
|
|
return (
|
|
<ClientView
|
|
ticket={ticket}
|
|
clientUrl={clientUrl || "/nitro-client/"}
|
|
hotelName={hotelName}
|
|
initialOnline={onlineCount}
|
|
/>
|
|
);
|
|
}
|