-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
44 lines (34 loc) · 969 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict'
var express = require('express'),
app = express(),
bodyParser = require('body-parser');
// parse incoming requests
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
// link static files from dirname to public
app.use(express.static(__dirname + '/public'));
//pug engine setup
app.set('view engine', 'pug');
app.set('views', __dirname + '/views');
//include routes from route
var routes = require('./controllers/routes');
app.use('/', routes);
//handle status 404 page not found
app.use(function(req, res, next) {
var err = new Error('Page not found');
err.status = 404;
next(err);
});
//error handler
//define last callback
app.use(function(err, req,res,next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});
//listen to port 5000 and send message to console
app.listen(process.env.PORT || 5000, function() {
console.log('Jobdrop app started at port')
});