Add authentication endpoints & refactor

This commit is contained in:
Myx
2024-05-12 14:36:10 +02:00
parent 35de8b294d
commit 99b1ee39df
10 changed files with 280 additions and 130 deletions

View File

@@ -0,0 +1,44 @@
import express from 'express';
import path from 'path';
import { Handlers } from "../handlers/index";
import { nextPlayBackTime } from '../../bot';
import { loadAvoidList } from '../../helpers/load-avoid-list';
const router = express.Router();
/**
* Returns the next playback time.
* @returns string - The next playback time.
*/
router.get('/nextplaybacktime', (_req, res) => {
res.send(nextPlayBackTime);
});
/**
* Returns the index.html file.
* @returns index.html - The index.html file.
*/
router.get('/', (_req, res) => {
res.sendFile(path.join(__dirname, '../web/index.html'));
});
router.get('/avoidlist', (_req, res) => {
res.send(loadAvoidList());
});
router.post('/avoidlist', (req, res) => {
Handlers.AddUserToAvoidList(res, req);
});
router.delete('/avoidlist/:user', (req, res) => {
Handlers.DeleteUserFromAvoidList(res, req);
});
router.get('/join', (_req, res) => {
Handlers.JoinChannel(res);
});
router.use(express.static(path.join(__dirname, "../web")));
export default router;