Fix muxing
This commit is contained in:
40
dist/server/routes/config.js
vendored
40
dist/server/routes/config.js
vendored
@@ -2,10 +2,43 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const express_1 = require("express");
|
||||
const jobStore_1 = require("../db/jobStore");
|
||||
const config_1 = require("../../config/config");
|
||||
const router = (0, express_1.Router)();
|
||||
// Optional .env overrides for the (long) prompt strings — keep getDefaultConfig()'s
|
||||
// hardcoded prompts as the final fallback. Users who want to tweak prompts without
|
||||
// editing source can set these in .env, or set them per-job in the Settings UI.
|
||||
const ENV_OVERRIDES = {
|
||||
defaultPrompt: process.env.AIDIO_DEFAULT_PROMPT,
|
||||
changePrompt: process.env.AIDIO_CHANGE_PROMPT,
|
||||
batchPrompt: process.env.AIDIO_BATCH_PROMPT,
|
||||
};
|
||||
// Fields in Config that are nested objects (provider configs, etc.) and shouldn't
|
||||
// be flattened into the form-facing config map. API keys live inside these — keep
|
||||
// them off the wire.
|
||||
const NESTED_FIELDS = new Set(['visionProviders', 'ttsProviders']);
|
||||
function buildLayeredConfig() {
|
||||
const defaults = (0, config_1.getDefaultConfig)();
|
||||
const db = (0, jobStore_1.getAllConfig)();
|
||||
const merged = {};
|
||||
for (const [key, value] of Object.entries(defaults)) {
|
||||
if (NESTED_FIELDS.has(key))
|
||||
continue;
|
||||
if (value === undefined || value === null)
|
||||
continue;
|
||||
merged[key] = String(value);
|
||||
}
|
||||
for (const [key, value] of Object.entries(ENV_OVERRIDES)) {
|
||||
if (value !== undefined && value !== '')
|
||||
merged[key] = value;
|
||||
}
|
||||
for (const [key, value] of Object.entries(db)) {
|
||||
if (value !== undefined && value !== '')
|
||||
merged[key] = value;
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
router.get('/', (_req, res) => {
|
||||
const config = (0, jobStore_1.getAllConfig)();
|
||||
res.json({ config });
|
||||
res.json({ config: buildLayeredConfig() });
|
||||
});
|
||||
router.put('/', (req, res) => {
|
||||
const updates = req.body;
|
||||
@@ -16,8 +49,7 @@ router.put('/', (req, res) => {
|
||||
for (const [key, value] of Object.entries(updates)) {
|
||||
(0, jobStore_1.setConfigValue)(key, String(value));
|
||||
}
|
||||
const config = (0, jobStore_1.getAllConfig)();
|
||||
res.json({ config });
|
||||
res.json({ config: buildLayeredConfig() });
|
||||
});
|
||||
exports.default = router;
|
||||
//# sourceMappingURL=config.js.map
|
||||
Reference in New Issue
Block a user