bigly-chat/routes.js

40 lines
763 B
JavaScript
Raw Normal View History

2024-09-07 18:12:58 -04:00
import main from "./client/main.js";
import auth from "./form/auth.js";
import login from "./client/login.js";
import register from "./client/register.js";
import loginB from "./form/login.js";
import registerB from "./form/register.js";
const routes = {
get: {},
form: {},
client: {}
};
routes.client = {
main,
login,
register
}
routes.get = {
};
routes.form = {
login: loginB,
register: registerB,
auth
};
async function iterate(req, res, index) {
let routesI = routes[index];
let keys = Object.keys(routesI);
let cmd = req.params.route;
2024-09-19 05:04:03 -04:00
if (keys.indexOf(cmd) == -1) {
res.status(404).send('fail');
return;
}
2024-09-07 18:12:58 -04:00
return await routesI[cmd].run(req, res, {});
}
export default iterate;