mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00

* fix: sanitize HTTP params and do not send whole error objects backs * fix: prevent path traversal * fix: send custom error message for tokenizer route * chore: handle info exposure vector * chore(oauth): skip check due to false positive as oauth routes are rate-limited * chore(app): disable `x-powered-by` * chore: disable false positives or flagging of hardcoded secrets when they are fake values * chore: add path traversal safety check
18 lines
564 B
JavaScript
18 lines
564 B
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const requireJwtAuth = require('~/server/middleware/requireJwtAuth');
|
|
const { countTokens } = require('~/server/utils');
|
|
const { logger } = require('~/config');
|
|
|
|
router.post('/', requireJwtAuth, async (req, res) => {
|
|
try {
|
|
const { arg } = req.body;
|
|
const count = await countTokens(arg?.text ?? arg);
|
|
res.send({ count });
|
|
} catch (e) {
|
|
logger.error('[/tokenizer] Error counting tokens', e);
|
|
res.status(500).json('Error counting tokens');
|
|
}
|
|
});
|
|
|
|
module.exports = router;
|