Phase 3 (WIP): Refactor license, credentials, backups routes
- All use explicit deps instead of ctx - Pattern consistent across all refactored routes
This commit is contained in:
@@ -1,36 +1,32 @@
|
||||
const express = require('express');
|
||||
const asyncHandler = require('../src/utils/async-handler');
|
||||
|
||||
module.exports = function(ctx) {
|
||||
module.exports = function({ backupManager }) {
|
||||
const router = express.Router();
|
||||
|
||||
// Get backup configuration
|
||||
router.get('/backups/config', ctx.asyncHandler(async (req, res) => {
|
||||
const config = ctx.backupManager.getConfig();
|
||||
router.get('/backups/config', asyncHandler(async (req, res) => {
|
||||
const config = backupManager.getConfig();
|
||||
res.json({ success: true, config });
|
||||
}, 'backups-config-get'));
|
||||
|
||||
// Update backup configuration
|
||||
router.post('/backups/config', ctx.asyncHandler(async (req, res) => {
|
||||
ctx.backupManager.updateConfig(req.body);
|
||||
router.post('/backups/config', asyncHandler(async (req, res) => {
|
||||
backupManager.updateConfig(req.body);
|
||||
res.json({ success: true, message: 'Backup configuration updated' });
|
||||
}, 'backups-config-update'));
|
||||
|
||||
// Execute manual backup
|
||||
router.post('/backups/execute', ctx.asyncHandler(async (req, res) => {
|
||||
const backup = await ctx.backupManager.executeBackup('manual', req.body);
|
||||
router.post('/backups/execute', asyncHandler(async (req, res) => {
|
||||
const backup = await backupManager.executeBackup('manual', req.body);
|
||||
res.json({ success: true, backup });
|
||||
}, 'backups-execute'));
|
||||
|
||||
// Get backup history
|
||||
router.get('/backups/history', ctx.asyncHandler(async (req, res) => {
|
||||
router.get('/backups/history', asyncHandler(async (req, res) => {
|
||||
const limit = parseInt(req.query.limit) || 50;
|
||||
const history = ctx.backupManager.getHistory(limit);
|
||||
const history = backupManager.getHistory(limit);
|
||||
res.json({ success: true, history });
|
||||
}, 'backups-history'));
|
||||
|
||||
// Restore from backup
|
||||
router.post('/backups/restore/:backupId', ctx.asyncHandler(async (req, res) => {
|
||||
const result = await ctx.backupManager.restoreBackup(req.params.backupId, req.body);
|
||||
router.post('/backups/restore/:backupId', asyncHandler(async (req, res) => {
|
||||
const result = await backupManager.restoreBackup(req.params.backupId, req.body);
|
||||
res.json({ success: true, result });
|
||||
}, 'backups-restore'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user