40 lines
No EOL
763 B
JavaScript
40 lines
No EOL
763 B
JavaScript
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;
|
|
if (keys.indexOf(cmd) == -1) {
|
|
res.status(404).send('fail');
|
|
return;
|
|
}
|
|
|
|
return await routesI[cmd].run(req, res, {});
|
|
}
|
|
|
|
export default iterate; |