Hi there, I've been tasked with something at work that's beyond my current skills so any help is appreciated.I'm building an admin where you can add "games". Each game needs to have it's own front-end, routes, and logic.Kinda like, mainsite.com/game/game1mainsite.com/game/game2mainsite.com/game/game3At the moment I'm just creating a directory based on the game name. var dir = "./games/" + req.body.gameId; if (!fs.existsSync(dir)) { fs.mkdirSync(dir); } In turn I can pull the .ejs file via:/* GET dynamic game page. */ router.get("/game/:game", function(req, res, next) { res.render("../games/"+req.params.game+"/index", { title: "Express" }); }); But I am confused on how it can have it's own logic, routes, connecting to database, front-end, stylesheets inside it's own folder.There must be a better way to achieve this right?Cheers
Submitted August 05, 2019 at 05:15AM by CyrisXD
No comments:
Post a Comment