fix: improved searchs

This commit is contained in:
Lukian 2025-05-12 11:43:23 +02:00
parent fb90f1ef4f
commit b2d8acaa5d
9 changed files with 39 additions and 50 deletions

View file

@ -15,7 +15,8 @@ const {
addAttachment,
getMessageAttachments,
getUnusedAttachments,
deleteUnusedAttachments
deleteUnusedAttachments,
searchChannels
} = require('../libs/mysql');
const rateLimit = require("express-rate-limit");
const slowDown = require("express-slow-down");
@ -43,7 +44,13 @@ const speedLimiter = slowDown({
const router = express.Router();
router.get('/', async (req, res) => {
const { search } = req.query;
const connection = await getConnection();
if (search) {
const channels = await searchChannels(connection, search);
connection.end();
return res.send(channels);
}
const channels = await getChannels(connection);
connection.end();
res.send(channels);