feat(handlers): Add generic error handler

This commit is contained in:
Khaled Garbaya
2017-10-04 10:36:04 +02:00
committed by Benedikt Rötsch
parent 01fd3cc9b3
commit 67fc0edf62
6 changed files with 42 additions and 30 deletions

View File

@@ -1,11 +1,12 @@
const express = require('express')
const {getLandingPage} = require('../services/contentful')
const { getLandingPage } = require('../services/contentful')
const { catchErrors } = require('../handlers/errorHandlers')
const router = express.Router()
/* GET home page. */
router.get('/', async function (req, res, next) {
router.get('/', catchErrors(async function (req, res, next) {
const landingPage = await getLandingPage(req.query.locale, req.query.api)
res.render('index', { title: 'Contentful University', landingPage })
})
}))
module.exports = router