From 750fcb2e5ca70d21c6a825660b6aeb817e038b5c Mon Sep 17 00:00:00 2001 From: openhands Date: Thu, 27 Aug 2026 16:42:12 +0200 Subject: [PATCH] refactor: resolve hotel name directly from HOTEL_NAME env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit resolveHotelName() now returns env.HOTEL_NAME directly — the single source of truth. The CMS hotel_name site setting and its DEFAULTS entry are removed as dead code since they no longer influence the displayed name. Call sites are unchanged (still await resolveHotelName()); only the lookup behind it is gone, so the public site always shows the configured env name with no DB round-trip and no preset. --- src/app/admin/settings/cms-settings-config.ts | 7 ------- src/lib/hotel-name.ts | 12 ++++-------- src/lib/services/site-settings.ts | 3 +-- vitest.config.ts | 1 + 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/app/admin/settings/cms-settings-config.ts b/src/app/admin/settings/cms-settings-config.ts index 7b099f10..dc33a47e 100644 --- a/src/app/admin/settings/cms-settings-config.ts +++ b/src/app/admin/settings/cms-settings-config.ts @@ -44,13 +44,6 @@ export const SETTINGS_GROUPS: SettingsGroup[] = [ icon: "building", description: "Name, branding and defaults shown across the site.", fields: [ - { - key: "hotel_name", - label: "Hotel name", - type: "text", - placeholder: "Epicnabbo", - defaultValue: "", - }, { key: "cms_logo", label: "Logo URL", diff --git a/src/lib/hotel-name.ts b/src/lib/hotel-name.ts index 2ec742c6..cdf9044a 100644 --- a/src/lib/hotel-name.ts +++ b/src/lib/hotel-name.ts @@ -1,16 +1,12 @@ import "server-only"; import { env } from "@/env"; -import { siteSettings } from "@/lib/services/site-settings"; /** - * 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. + * The public hotel name is read directly from the required HOTEL_NAME env var. + * There is no CMS override or hardcoded preset — the site must be configured, + * otherwise HOTEL_NAME fails validation at startup. */ export async function resolveHotelName(): Promise { - const fromSettings = ( - await siteSettings.get("hotel_name", env.HOTEL_NAME) - )?.trim(); - return fromSettings || env.HOTEL_NAME; + return env.HOTEL_NAME; } diff --git a/src/lib/services/site-settings.ts b/src/lib/services/site-settings.ts index 42abc845..a008e288 100644 --- a/src/lib/services/site-settings.ts +++ b/src/lib/services/site-settings.ts @@ -5,7 +5,6 @@ import { logger } from "@/lib/logger"; import { redis } from "@/lib/redis"; const DEFAULTS: Record = { - hotel_name: "", habbo_imaging_url: "/imaging", logo_url: "", nitro_client_url: "", @@ -15,7 +14,7 @@ const DEFAULTS: Record = { const CACHE_TTL_MS = 300_000; const REDIS_CACHE_KEY = "site_settings"; // Short in-process window so repeated getters in one request (header, nav, -// footer all read hotel_name / logo) don't each pay a Redis round-trip. +// footer all read logo and other settings) don't each pay a Redis round-trip. // Redis stays the source of truth across instances. const MEMORY_TTL_MS = 60_000; diff --git a/vitest.config.ts b/vitest.config.ts index 7d8e89b9..d11f9789 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -19,6 +19,7 @@ export default defineConfig({ // unit tests run without a populated .env. env: { SKIP_ENV_VALIDATION: "1", + HOTEL_NAME: "TestHotel", DATABASE_URL: "mysql://root:root@localhost:3306/test", }, testTimeout: 10000,