I have an admin panel where I customize things like my site's name, tagline, &c. The below code does exactly what I want it to do, but only for the index page:
app.get("/", function (req, res) {
app.service("customization").find().then(function (result) {
res.render("index", Object.assign({ layout: "layouts/default" }, result[0]));
});
});
How do I make this apply to all routes (so, the entire site)? I've tried placing *
in place of /
, but that hasn't helped.
EDIT: Replacing /
with *
and placing this bit of code before all my routes made every page render my index
view, which is not ideal. For the time being, I will just duplicate this code for each route, changing the route and view options. I have code like this:
app.get("/admin/:page", require("connect-ensure-login").ensureLoggedIn("/admin"), function (req, res) {
app.service("customization").find().then(function (result) {
res.render("admin/" + req.params.page, Object.assign({ user: req.user, title: "Admin", layout: "layouts/admin" }, result[0]));
});
});
To ensure I'm not duplication too much, but still...