feat: editable settings page with .env write and container restart

- Add settings form with all config fields (Bot, Commission, Wallets, WireGuard)
- POST handler writes .env file and restarts container via process.exit(0)
- Secrets (ENCRYPTION_KEY, ADMIN_SECRET, GITEA_TOKEN, WG_PRIVATE_KEY, WG_PRESHARED_KEY)
  are never sent to browser - masked placeholders used instead
- PRESERVE_KEYS enforced: secret keys cannot be overwritten via form
- Values sanitized: newlines stripped before writing to .env
- start.sh loads .env file before node to override Docker env_file cache
- Extract shared escapeHtml utility to escape.js (used by 6 view files)
- Update paymentWallets view to link to Settings page instead of .env
- Add .env volume mount for settings panel read/write
- Fix registerRoutes() not being called in index.js (bot menu buttons)
This commit is contained in:
NW
2026-06-23 12:32:25 +01:00
parent 935c6df1dc
commit 6db770b96b
12 changed files with 199 additions and 61 deletions

View File

@@ -1,6 +1,6 @@
import 'dotenv/config';
import { runMigrations, cleanUpInvalidForeignKeys } from './migrations/runner.js';
import './router/routes.js';
import { registerRoutes } from './router/routes.js';
import bot from './context/bot.js';
import ErrorHandler from './utils/errorHandler.js';
import logger from './utils/logger.js';
@@ -14,6 +14,7 @@ import { initStates } from './services/stateService.js';
await runMigrations();
await cleanUpInvalidForeignKeys();
await initStates();
registerRoutes();
const logDebug = (action, functionName) => {
logger.debug({ action, functionName }, 'Button Press');