bigly-chat/routes.js
2024-11-25 08:24:18 -05:00

76 lines
No EOL
1.7 KiB
JavaScript

import main from "./client/main.js";
import login from "./client/login.js";
import register from "./client/register.js";
import upload from "./client/upload.js";
import player from "./client/player.js";
import user from "./client/user.js";
import settings from "./client/settings.js";
import e404 from "./client/e404.js";
import tou from "./client/tou.js";
import captcha from './client/captcha.js';
import messages from './client/messages.js';
import loginB from "./form/login.js";
import registerB from "./form/register.js";
import uploadB from "./form/upload.js";
import commentB from "./form/comment.js";
import settingsB from "./form/settings.js";
import auth from "./form/auth.js";
import auth_api from "./form/auth_api.js";
import delete_video from "./form/delete_video.js";
import follow from './form/follow.js';
const routes = {
get: {},
form: {},
client: {},
};
routes.client = {
main,
login,
register,
upload,
video: player,
user,
settings,
e404,
tou,
captcha,
messages
}
routes.get = {
};
routes.form = {
login: loginB,
register: registerB,
upload: uploadB,
auth,
comment: commentB,
follow,
settings: settingsB,
auth_api,
delete_video
};
async function iterate(req, res, index) {
let routesI = routes[index];
let keys = Object.keys(routesI);
let cmd = req.params.route;
if (keys.indexOf(cmd) == -1) {
return await routes.client['e404'].run(req, res, {});
}
let dat = await routesI[cmd].run(req, res, {});
if (!dat && !res.headersSent) {
console.log(res)
return await routes.client['e404'].run(req, res, {});
}
return dat;
}
export default iterate;