homepage.js/routes/proj.js

40 lines
961 B
JavaScript
Raw Permalink Normal View History

2023-03-12 03:28:05 +01:00
const handler = require('express-async-handler');
2023-03-17 11:53:27 +01:00
const Helpers = require('../helpers');
2023-02-18 14:41:24 +01:00
2023-03-12 03:28:05 +01:00
async function project(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) => {
2023-03-12 03:28:05 +01:00
router.get('/project', handler(project));
router.get('/project/:id', handler(viewer));
2023-02-18 14:41:24 +01:00
}