homepage.js/routes/proj.js

39 lines
893 B
JavaScript
Raw Normal View History

2023-02-18 14:41:24 +01:00
const Helpers = require('../helpers');
async function handler(req, res) {
2023-03-11 16:54:53 +01:00
res.template(
'project.pug',
{
current_route: '/project'
}
2023-02-18 14:41:24 +01:00
);
return;
}
async function viewer(req, res) {
const id = req.params.id;
const view = 'projects/' + id + '.pug';
if (!(await Helpers.ViewLoader.exists(view))) {
2023-03-11 16:54:53 +01:00
res.status(404).template(
'error.pug',
{
current_route: req.originalUrl,
error: '404 Not Found',
message: 'Requested project does not exists. Are you sure this is the valid link?'
}
2023-02-18 14:41:24 +01:00
);
return;
}
2023-03-11 16:54:53 +01:00
res.template(
view,
{
current_route: req.originalUrl
}
2023-02-18 14:41:24 +01:00
)
}
module.exports = (router) => {
router.get('/project', handler);
router.get('/project/:id', viewer);
}