feat: dukung SETTINGS_PATH (settings.json di direktori mount/persisten)
This commit is contained in:
1 parent
f27c02309e
commit
6f97430e41
6 files changed
+12
-5
No files matched your search
@@ -0,0 +1,7 @@
|
||||
// Lokasi file settings.json — dapat diarahkan via env SETTINGS_PATH
|
||||
// (dipakai agar settings bisa disimpan di direktori yang di-mount / persisten).
|
||||
const path = require('path');
|
||||
const settingsPath = process.env.SETTINGS_PATH
|
||||
? path.resolve(process.env.SETTINGS_PATH)
|
||||
: path.join(__dirname, '..', 'settings.json');
|
||||
module.exports = { settingsPath };
|
||||
@@ -17,7 +17,7 @@ let settingsCacheTime = 0;
|
||||
const CACHE_DURATION = 2000; // 2 detik
|
||||
|
||||
// File system watcher untuk auto-reload settings
|
||||
const settingsPath = path.join(__dirname, '../settings.json');
|
||||
const { settingsPath } = require('./paths');
|
||||
let watcher = null;
|
||||
|
||||
// Helper untuk baca settings.json secara dinamis
|
||||
|
||||
+1
-1
@@ -1318,7 +1318,7 @@ router.put('/api/servers/legacy', requireAdmin, express.json(), async (req, res)
|
||||
if (clearPassword) currentSettings.genieacs_password = '';
|
||||
else if (String(passwordInput || '').trim()) currentSettings.genieacs_password = String(passwordInput || '');
|
||||
|
||||
const settingsPath = path.join(__dirname, '../settings.json');
|
||||
const settingsPath = require('../config/paths').settingsPath;
|
||||
fs.writeFileSync(settingsPath, JSON.stringify(currentSettings, null, 2), 'utf8');
|
||||
|
||||
res.json({ success: true, message: 'Default ACS berhasil diperbarui.' });
|
||||
|
||||
@@ -5234,7 +5234,7 @@ router.post('/api/genieacs/settings', requireAdmin, async (req, res) => {
|
||||
// Save to file
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const settingsPath = path.join(__dirname, '../settings.json');
|
||||
const settingsPath = require('../config/paths').settingsPath;
|
||||
fs.writeFileSync(settingsPath, JSON.stringify(currentSettings, null, 2), 'utf8');
|
||||
|
||||
// Log audit
|
||||
|
||||
@@ -2190,7 +2190,7 @@ router.post('/app/admin/settings/update', requireAdminApiAuth, (req, res) => {
|
||||
try {
|
||||
const allowed = ['company_header', 'company_subheader', 'company_phone', 'company_address', 'timezone', 'qris_enabled', 'auto_isolate_enabled', 'webhook_secret'];
|
||||
const updates = req.body || {};
|
||||
const settingsPath = require('path').join(__dirname, '../settings.json');
|
||||
const settingsPath = require('../config/paths').settingsPath;
|
||||
const current = JSON.parse(require('fs').readFileSync(settingsPath, 'utf8'));
|
||||
let changed = 0;
|
||||
for (const key of allowed) {
|
||||
|
||||
@@ -11,7 +11,7 @@ const { getSetting, getCurrentDateInTimezone, getNowLocalISO } = require('../con
|
||||
const projectRoot = path.join(__dirname, '..');
|
||||
const backupDir = path.join(projectRoot, 'backups');
|
||||
const dbPath = path.join(projectRoot, 'database', 'billing.db');
|
||||
const settingsPath = path.join(projectRoot, 'settings.json');
|
||||
const { settingsPath } = require('../config/paths');
|
||||
|
||||
// Pastikan direktori backup ada
|
||||
if (!fs.existsSync(backupDir)) {
|
||||
|
||||
Reference in new issue
Block a user