diff --git a/database/db_connection.js b/database/db_connection.js index 2081553..38d3e35 100644 --- a/database/db_connection.js +++ b/database/db_connection.js @@ -1,5 +1,5 @@ const mongoose = require('mongoose'); -require('env2')('./congif.env'); +require('env2')('./config.env'); const db = mongoose.connection; mongoose.connect(process.env.MONGODB_URI, { diff --git a/src/controllers/error.js b/src/controllers/error.js new file mode 100644 index 0000000..21220bd --- /dev/null +++ b/src/controllers/error.js @@ -0,0 +1,15 @@ +exports.client = (req, res) => { + res.status(404).render('error', { + layout: 'error', + statusCode: 404, + message: 'What are you looking for?' + }); +}; + +exports.server = (req, res) => { + res.status(500).render('error', { + layout: 'error', + statusCode: 500, + message: 'Sorry we are pretty ill right now. Hopefully we will get better soon' + }); +}; diff --git a/src/controllers/router.js b/src/controllers/router.js index 0bd2fe4..16d4a64 100644 --- a/src/controllers/router.js +++ b/src/controllers/router.js @@ -1,8 +1,12 @@ const express = require('express'); const router = express.Router(); +const error = require('./error'); const career = require('./career'); router.get('/career', career); +router.use(error.client); +router.use(error.server); + module.exports = router; diff --git a/src/views/error.hbs b/src/views/error.hbs new file mode 100644 index 0000000..d042adc --- /dev/null +++ b/src/views/error.hbs @@ -0,0 +1,4 @@ +
+

Status code: {{statusCode}}.

+

{{message}}

+
diff --git a/src/views/layouts/error.hbs b/src/views/layouts/error.hbs new file mode 100644 index 0000000..20a2b34 --- /dev/null +++ b/src/views/layouts/error.hbs @@ -0,0 +1,9 @@ + + + {{>html_head}} + +
+ {{{body}}} +
+ +