Working version before modification.
This commit is contained in:
@@ -2,9 +2,11 @@ import { Router } from 'express';
|
||||
|
||||
import {
|
||||
getAppConfig,
|
||||
getAppConfigValue,
|
||||
getExportProfile,
|
||||
getImageRules,
|
||||
updateImageRules
|
||||
updateImageRules,
|
||||
upsertAppConfig
|
||||
} from '../services/configService.js';
|
||||
import { logAuditEvent } from '../services/auditService.js';
|
||||
import { asyncHandler } from '../utils/asyncHandler.js';
|
||||
@@ -154,4 +156,36 @@ router.get(
|
||||
})
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/app-config/:key',
|
||||
asyncHandler(async (req, res) => {
|
||||
const value = await getAppConfigValue(req.params.key);
|
||||
|
||||
if (value === null) {
|
||||
return res.status(404).json({ message: 'Config key not found.' });
|
||||
}
|
||||
|
||||
return res.json({ key: req.params.key, value });
|
||||
})
|
||||
);
|
||||
|
||||
router.put(
|
||||
'/app-config/:key',
|
||||
asyncHandler(async (req, res) => {
|
||||
const key = req.params.key;
|
||||
|
||||
if (!key || typeof key !== 'string' || key.length > 100) {
|
||||
return res.status(400).json({ message: 'Invalid config key.' });
|
||||
}
|
||||
|
||||
if (req.body?.value === undefined) {
|
||||
return res.status(400).json({ message: 'Request body must include a value property.' });
|
||||
}
|
||||
|
||||
const result = await upsertAppConfig(key, req.body.value);
|
||||
configCache.invalidate(key);
|
||||
return res.json(result);
|
||||
})
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user