modified version
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
import { Router } from 'express';
|
||||
|
||||
import {
|
||||
getAppConfig,
|
||||
getAppConfigValue,
|
||||
getExportProfile,
|
||||
getImageRules,
|
||||
updateImageRules,
|
||||
upsertAppConfig
|
||||
updateImageRules
|
||||
} from '../services/configService.js';
|
||||
import { logAuditEvent } from '../services/auditService.js';
|
||||
import { asyncHandler } from '../utils/asyncHandler.js';
|
||||
@@ -143,49 +140,4 @@ router.get(
|
||||
})
|
||||
);
|
||||
|
||||
router.get(
|
||||
'/app-config',
|
||||
asyncHandler(async (_req, res) => {
|
||||
/*
|
||||
* Generic application configuration is kept as a simple key/value list in
|
||||
* the PoC. This avoids hardcoding small behavioral settings in the frontend
|
||||
* while still keeping the schema easy to inspect and evolve.
|
||||
*/
|
||||
const config = await getAppConfig();
|
||||
res.json({ items: config });
|
||||
})
|
||||
);
|
||||
|
||||
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