const express = require('express');
const { getConnection, searchChannels } = require('../libs/mysql');

const router = express.Router();

router.get('/', async (req, res) => {
    const { search } = req.query;
    const connection = await getConnection();
    const channels = await searchChannels(connection, search);
    connection.end();
    res.send(channels);
});

module.exports = router;