refactor(config): Extract configuration into src/config/ module
- Create src/config/paths.js for all file paths and env vars - Create src/config/site.js for site configuration loading - Create src/config/index.js as unified config export - Prepare for server.js modularization (Phase 2.1) Part of deslopification roadmap: break 1997-line server.js into layers
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Platform-specific paths and environment variable configuration
|
||||
*/
|
||||
const path = require('path');
|
||||
const platformPaths = require('../../platform-paths');
|
||||
|
||||
const CADDYFILE_PATH = process.env.CADDYFILE_PATH || platformPaths.caddyfile;
|
||||
const CADDY_ADMIN_URL = process.env.CADDY_ADMIN_URL || platformPaths.caddyAdminUrl;
|
||||
const SERVICES_FILE = process.env.SERVICES_FILE || platformPaths.servicesFile;
|
||||
const SERVICES_DIR = path.dirname(SERVICES_FILE);
|
||||
const CONFIG_FILE = process.env.CONFIG_FILE || path.join(SERVICES_DIR, 'config.json');
|
||||
const DNS_CREDENTIALS_FILE = process.env.DNS_CREDENTIALS_FILE || path.join(SERVICES_DIR, 'dns-credentials.json');
|
||||
const TAILSCALE_CONFIG_FILE = process.env.TAILSCALE_CONFIG_FILE || path.join(SERVICES_DIR, 'tailscale-config.json');
|
||||
const NOTIFICATIONS_FILE = process.env.NOTIFICATIONS_FILE || path.join(SERVICES_DIR, 'notifications.json');
|
||||
const TOTP_CONFIG_FILE = process.env.TOTP_CONFIG_FILE || path.join(SERVICES_DIR, 'totp-config.json');
|
||||
const ERROR_LOG_FILE = process.env.ERROR_LOG_FILE || path.join(__dirname, '../../dashcaddy-errors.log');
|
||||
const LICENSE_SECRET_FILE = process.env.LICENSE_SECRET_FILE || path.join(__dirname, '../../.license-secret');
|
||||
|
||||
const BROWSE_ROOTS = (process.env.MEDIA_BROWSE_ROOTS || '')
|
||||
.split(',')
|
||||
.filter(r => r.includes('='))
|
||||
.map(r => {
|
||||
const eqIndex = r.indexOf('=');
|
||||
const containerPath = r.slice(0, eqIndex).trim();
|
||||
const hostPath = r.slice(eqIndex + 1).trim();
|
||||
return { containerPath, hostPath };
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
CADDYFILE_PATH,
|
||||
CADDY_ADMIN_URL,
|
||||
SERVICES_FILE,
|
||||
SERVICES_DIR,
|
||||
CONFIG_FILE,
|
||||
DNS_CREDENTIALS_FILE,
|
||||
TAILSCALE_CONFIG_FILE,
|
||||
NOTIFICATIONS_FILE,
|
||||
TOTP_CONFIG_FILE,
|
||||
ERROR_LOG_FILE,
|
||||
LICENSE_SECRET_FILE,
|
||||
BROWSE_ROOTS,
|
||||
};
|
||||
Reference in New Issue
Block a user