49 lines
No EOL
986 B
JavaScript
49 lines
No EOL
986 B
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 loginB from "./form/login.js";
|
|
import registerB from "./form/register.js";
|
|
import uploadB from "./form/upload.js";
|
|
import auth from "./form/auth.js";
|
|
|
|
const routes = {
|
|
get: {},
|
|
form: {},
|
|
client: {},
|
|
};
|
|
|
|
routes.client = {
|
|
main,
|
|
login,
|
|
register,
|
|
upload,
|
|
video: player,
|
|
user
|
|
}
|
|
routes.get = {
|
|
};
|
|
routes.form = {
|
|
login: loginB,
|
|
register: registerB,
|
|
upload: uploadB,
|
|
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; |