spee.ch/routes/home-routes.js

16 lines
476 B
JavaScript
Raw Normal View History

const { postToStats } = require('../controllers/statsController.js');
module.exports = app => {
// route for the home page
app.get('/', (req, res) => {
res.status(200).render('index');
});
// a catch-all route if someone visits a page that does not exist
app.use('*', ({ originalUrl, ip }, res) => {
2017-06-30 02:10:14 +02:00
// post to stats
2017-07-13 00:30:31 +02:00
postToStats('show', originalUrl, ip, null, null, 'Error: 404');
2017-06-30 02:10:14 +02:00
// send response
res.status(404).render('fourOhFour');
});
};