create custom view for redirect and custom view for not found

This commit is contained in:
Bilal Catic
2019-10-10 00:49:48 +02:00
parent 20a93b7fdc
commit 40fb1e6ad7
4 changed files with 65 additions and 4 deletions

View File

@@ -11,6 +11,30 @@ const redirect = async (req, res) => {
}
};
module.exports = {
redirect
const getRedirect = async (req, res) => {
const id = req.params.id || null;
let error = false;
let redirectUrl = undefined;
if (!id) {
error = true;
} else {
const realEstate = await getRealEstateById(id);
if (!realEstate) {
error = true;
} else {
redirectUrl = realEstate.url;
}
}
if (error) {
const title = "";
res.render("notFound", { title });
} else {
const title = "Preusmjeravanje";
res.render("redirect", { title, redirectUrl });
}
};
module.exports = {
getRedirect
};