Files
EpicNext-Cms/src/app/api/home/route.ts
T
SimoandCursor e00e9ca2dc
Deploy / release (push) Skipped
Deploy / deploy (push) Successful in 2m6s
refactor: centralize hotel name fallback via FALLBACK_HOTEL_NAME
Route all user-facing Atom hotel defaults through resolveHotelName (settings then HOTEL_NAME env then brand constant). Exclude Playwright e2e from tsconfig until deps are installed.

Co-authored-by: Cursor <[email protected]>
2026-07-22 18:45:59 +02:00

44 lines
1.2 KiB
TypeScript

import { FALLBACK_HOTEL_NAME } from "@/lib/brand";
import { apiJson } from "@/lib/api";
import { resolveHotelName } from "@/lib/hotel-name";
import { prisma } from "@/lib/prisma";
import { redisCache, apiCacheKey } from "@/lib/redis-cache";
export const dynamic = "force-dynamic";
/**
* GET /api/home — combined landing payload: the latest 4 website_articles and
* the current online player count (users.online === "1"). Mirrors the queries
* used by the public pages and the admin dashboard.
*/
export async function GET(_req: Request) {
try {
const data = await redisCache(
apiCacheKey("home"),
15,
async () => {
const [articles, online, hotelName] = await Promise.all([
prisma.websiteArticles.findMany({
select: {
id: true,
title: true,
slug: true,
shortStory: true,
image: true,
createdAt: true,
},
orderBy: { createdAt: "desc" },
take: 4,
}),
prisma.user.count({ where: { online: "1" } }),
resolveHotelName(),
]);
return { articles, online, hotelName };
},
);
return apiJson(data);
} catch {
return apiJson({ articles: [], online: 0, hotelName: FALLBACK_HOTEL_NAME }, { status: 200 });
}
}