Refactor theme validation to dynamically import themes from the source directory
All checks were successful
Build & Push Docker Image / build (push) Successful in 6m20s
All checks were successful
Build & Push Docker Image / build (push) Successful in 6m20s
This commit is contained in:
@@ -5,18 +5,14 @@ import fs from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { getDb } from '../config/database.js';
|
||||
import { authenticateToken, requireAdmin } from '../middleware/auth.js';
|
||||
import { themes } from '../../src/themes/index.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const router = Router();
|
||||
|
||||
// Allowlist of valid theme IDs (keep in sync with src/themes/index.js)
|
||||
const VALID_THEMES = new Set([
|
||||
'light', 'dark', 'dracula', 'mocha', 'latte', 'nord', 'tokyo-night',
|
||||
'gruvbox-dark', 'gruvbox-light', 'rose-pine', 'rose-pine-dawn',
|
||||
'solarized-dark', 'solarized-light', 'one-dark', 'github-dark', 'scrunkly-cat',
|
||||
]);
|
||||
const VALID_THEMES = new Set(themes.map(t => t.id));
|
||||
|
||||
// Ensure uploads/branding directory exists
|
||||
const brandingDir = path.join(__dirname, '..', '..', 'uploads', 'branding');
|
||||
|
||||
Reference in New Issue
Block a user