generated from lucien/api-template
fix: improved searchs
This commit is contained in:
parent
fb90f1ef4f
commit
b2d8acaa5d
9 changed files with 39 additions and 50 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue