memory settings implementation
This commit is contained in:
38
packages/orchestration-service/src/routes/settings.js
Normal file
38
packages/orchestration-service/src/routes/settings.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const { Router } = require('express');
|
||||
const settings = require('../config/settings');
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
res.json(settings.load());
|
||||
});
|
||||
|
||||
router.patch('/', (req, res) => {
|
||||
const { recentEpisodeLimit, semanticLimit, scoreThreshold } = req.body;
|
||||
const updates = {};
|
||||
|
||||
if (recentEpisodeLimit !== undefined) {
|
||||
const val = Number(recentEpisodeLimit);
|
||||
if (!Number.isInteger(val) || val < 1 || val > 20)
|
||||
return res.status(400).json({ error: 'recentEpisodeLimit must be 1–20' });
|
||||
updates.recentEpisodeLimit = val;
|
||||
}
|
||||
|
||||
if (semanticLimit !== undefined) {
|
||||
const val = Number(semanticLimit);
|
||||
if (!Number.isInteger(val) || val < 1 || val > 20)
|
||||
return res.status(400).json({ error: 'semanticLimit must be 1–20' });
|
||||
updates.semanticLimit = val;
|
||||
}
|
||||
|
||||
if (scoreThreshold !== undefined) {
|
||||
const val = Number(scoreThreshold);
|
||||
if (isNaN(val) || val < 0 || val > 1)
|
||||
return res.status(400).json({ error: 'scoreThreshold must be 0–1' });
|
||||
updates.scoreThreshold = val;
|
||||
}
|
||||
|
||||
res.json(settings.save(updates));
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user