- credentials.js (2 deps: credentialManager, asyncHandler) - backups.js (2 deps: backupManager, asyncHandler) - license.js (2 deps: licenseManager, asyncHandler) - errorlogs.js (3 deps: ERROR_LOG_FILE, auditLogger, asyncHandler) - themes.js (0 deps! Standalone route) Total: 9 routes refactored so far
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
const express = require('express');
|
|
const { success } = require('../response-helpers');
|
|
|
|
/**
|
|
* Backups routes factory
|
|
* @param {Object} deps - Explicit dependencies
|
|
* @param {Object} deps.backupManager - Backup management module
|
|
* @param {Function} deps.asyncHandler - Async route handler wrapper
|
|
* @returns {express.Router}
|
|
*/
|
|
module.exports = function({ backupManager, asyncHandler }) {
|
|
const router = express.Router();
|
|
|
|
// Get backup configuration
|
|
router.get('/backups/config', asyncHandler(async (req, res) => {
|
|
const config = backupManager.getConfig();
|
|
success(res, { config });
|
|
}, 'backups-config-get'));
|
|
|
|
// Update backup configuration
|
|
router.post('/backups/config', asyncHandler(async (req, res) => {
|
|
backupManager.updateConfig(req.body);
|
|
success(res, { message: 'Backup configuration updated' });
|
|
}, 'backups-config-update'));
|
|
|
|
// Execute manual backup
|
|
router.post('/backups/execute', asyncHandler(async (req, res) => {
|
|
const backup = await backupManager.executeBackup('manual', req.body);
|
|
success(res, { backup });
|
|
}, 'backups-execute'));
|
|
|
|
// Get backup history
|
|
router.get('/backups/history', asyncHandler(async (req, res) => {
|
|
const limit = parseInt(req.query.limit) || 50;
|
|
const history = backupManager.getHistory(limit);
|
|
success(res, { history });
|
|
}, 'backups-history'));
|
|
|
|
// Restore from backup
|
|
router.post('/backups/restore/:backupId', asyncHandler(async (req, res) => {
|
|
const result = await backupManager.restoreBackup(req.params.backupId, req.body);
|
|
success(res, { result });
|
|
}, 'backups-restore'));
|
|
|
|
return router;
|
|
};
|