mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-17 05:20:55 +00:00
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Votes / vote (full suite) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions
* fix: inspect stored file locators per message * fix: declare traversal diagnostics for isolated declaration builds * refactor: inject locator traversal reporting from application callers * fix: propagate traversal diagnostics across protected entry points * fix: complete middleware reporters and hydration message counts
60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
const crypto = require('crypto');
|
|
const express = require('express');
|
|
const { logger } = require('@librechat/data-schemas');
|
|
const {
|
|
reportLocatorTraversalFailure,
|
|
createContentFilter,
|
|
extractPresetContent,
|
|
projectStoredPresets,
|
|
} = require('@librechat/api');
|
|
const { getPresets, savePreset, deletePresets } = require('~/models');
|
|
const { requireJwtAuth, configMiddleware } = require('~/server/middleware');
|
|
|
|
const router = express.Router();
|
|
const filterPresetContent = createContentFilter({
|
|
onTraversalFailure: reportLocatorTraversalFailure,
|
|
getFilters: (req) => req.config?.filters,
|
|
extract: (req) => extractPresetContent(req.body),
|
|
});
|
|
|
|
router.use(requireJwtAuth);
|
|
|
|
router.get('/', configMiddleware, async (req, res) => {
|
|
const presets = projectStoredPresets(await getPresets(req.user.id), req.config?.filters);
|
|
res.status(200).json(presets);
|
|
});
|
|
|
|
router.post('/', configMiddleware, filterPresetContent, async (req, res) => {
|
|
const update = req.body || {};
|
|
|
|
update.presetId = update?.presetId || crypto.randomUUID();
|
|
|
|
try {
|
|
const preset = await savePreset(req.user.id, update);
|
|
res.status(201).json(preset);
|
|
} catch (error) {
|
|
logger.error('[/presets] error saving preset', error);
|
|
res.status(500).send('There was an error when saving the preset');
|
|
}
|
|
});
|
|
|
|
router.post('/delete', async (req, res) => {
|
|
let filter = {};
|
|
const { presetId } = req.body || {};
|
|
|
|
if (presetId) {
|
|
filter = { presetId };
|
|
}
|
|
|
|
logger.debug('[/presets/delete] delete preset filter', filter);
|
|
|
|
try {
|
|
const deleteCount = await deletePresets(req.user.id, filter);
|
|
res.status(201).json(deleteCount);
|
|
} catch (error) {
|
|
logger.error('[/presets/delete] error deleting presets', error);
|
|
res.status(500).send('There was an error deleting the presets');
|
|
}
|
|
});
|
|
|
|
module.exports = router;
|