feat(status-page): add theme and themeMode fields (backend)

## Changes
- Add `theme` (refined | modern | bold | editorial, default "refined") and
  `themeMode` (auto | light | dark, default "auto") fields to the StatusPage
  Mongoose model and the shared `StatusPage` type.
- Extend the create/update Zod validator to accept both fields optionally.
- Map both fields in the repository's `toEntity` so GET responses include them.
- Document both fields in the create and update endpoints in `openapi.json`.
- Add `STATUS_PAGE_THEMES_ENABLED` env var (default `true`) wired through
  `SettingsService` for ops-level rollback. When disabled, the controller
  strips theme fields on write and forces defaults on read.

## Notes
- No migration needed; Mongoose applies defaults for legacy documents.
- Controller short-circuits to zero-cost when the feature flag is on.
- `DEFAULT_STATUS_PAGE_THEME` / `DEFAULT_STATUS_PAGE_THEME_MODE` constants
  exported so the frontend PR can consume the same values.
This commit is contained in:
gorkem-bwl committed 2026-04-23 22:45:50 -04:00
1 parent 6ed0818bad
commit ad964446de
11 files changed
+408 -8

No files matched your search

+4
View File
@@ -1,5 +1,6 @@
import { z } from "zod";
import { DbTypes } from "@/types/settings.js";
import { booleanCoercion } from "./shared.js";
const envSchema = z.object({
// Server Configuration
@@ -20,6 +21,9 @@ const envSchema = z.object({
// Optional
ORIGIN: z.string().optional(),
// Feature flags
STATUS_PAGE_THEMES_ENABLED: booleanCoercion.default(true),
});
export type ValidatedEnv = z.infer<typeof envSchema>;
@@ -1,6 +1,6 @@
import { z } from "zod";
import { booleanCoercion } from "./shared.js";
import { StatusPageTypes } from "@/types/statusPage.js";
import { StatusPageTypes, StatusPageThemes, StatusPageThemeModes } from "@/types/statusPage.js";
//****************************************
// Status Page Validations
@@ -33,6 +33,8 @@ export const createStatusPageBodyValidation = z
showAdminLoginLink: booleanCoercion.optional(),
showInfrastructure: booleanCoercion.optional(),
removeLogo: z.union([z.literal("true"), z.literal("false")]).optional(),
theme: z.enum(StatusPageThemes).optional(),
themeMode: z.enum(StatusPageThemeModes).optional(),
})
.strip();