refactor: remove hotel-name fallback, fail fast when unconfigured
Drop the hardcoded FALLBACK_HOTEL_NAME ("Atom") preset and the brand.ts
module. HOTEL_NAME is now a required env var: if it (and the CMS hotel_name
setting) is missing the site fails validation at startup/build with a clear
message instead of silently rendering a placeholder hotel name.
resolveHotelName() resolves CMS hotel_name -> required HOTEL_NAME only.
Callers that used the preset (api/home route catch branch, CMS settings form
default, mobile-nav/logo-generator prop defaults) now use the configured name
or an empty default; the real name is already passed in by server parents.
This commit is contained in:
1 parent
555c783d55
commit
164a4f4ef6
8 files changed
+19
-30
No files matched your search
@@ -1,10 +0,0 @@
|
||||
/**
|
||||
* Single hardcoded fallback hotel brand.
|
||||
* Override order at runtime:
|
||||
* 1. website_settings.hotel_name
|
||||
* 2. HOTEL_NAME env
|
||||
* 3. this constant
|
||||
*
|
||||
* Safe for client components (no env / DB imports).
|
||||
*/
|
||||
export const FALLBACK_HOTEL_NAME = "Atom";
|
||||
@@ -1,17 +1,16 @@
|
||||
import "server-only";
|
||||
|
||||
import { env } from "@/env";
|
||||
import { FALLBACK_HOTEL_NAME } from "@/lib/brand";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
|
||||
/**
|
||||
* Resolve the public hotel name: CMS setting → HOTEL_NAME env → FALLBACK_HOTEL_NAME.
|
||||
* Resolve the public hotel name: CMS `hotel_name` setting, falling back to the
|
||||
* required HOTEL_NAME env var. There is no hardcoded preset — the site must be
|
||||
* configured, otherwise HOTEL_NAME fails validation at startup.
|
||||
*/
|
||||
export async function resolveHotelName(): Promise<string> {
|
||||
const fromSettings = await siteSettings.get("hotel_name", env.HOTEL_NAME);
|
||||
const trimmed = fromSettings?.trim();
|
||||
if (trimmed) return trimmed;
|
||||
const fromEnv = env.HOTEL_NAME?.trim();
|
||||
if (fromEnv) return fromEnv;
|
||||
return FALLBACK_HOTEL_NAME;
|
||||
const fromSettings = (
|
||||
await siteSettings.get("hotel_name", env.HOTEL_NAME)
|
||||
)?.trim();
|
||||
return fromSettings || env.HOTEL_NAME;
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
import "server-only";
|
||||
|
||||
import { FALLBACK_HOTEL_NAME } from "@/lib/brand";
|
||||
import { db, WebsiteSetting } from "@/lib/db";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { redis } from "@/lib/redis";
|
||||
|
||||
const DEFAULTS: Record<string, string> = {
|
||||
hotel_name: FALLBACK_HOTEL_NAME,
|
||||
hotel_name: "",
|
||||
habbo_imaging_url: "/imaging",
|
||||
logo_url: "",
|
||||
nitro_client_url: "",
|
||||
|
||||
Reference in new issue
Block a user