-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
42 lines (34 loc) · 1.17 KB
/
server.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
var express = require('express'),
path = require('path'),
app = express(),
defaultPort = 4444,
bodyParser = require('body-parser'),
cookieParser = require('cookie-parser'),
nunjucks = require('nunjucks'),
isProduction = process.env.NODE_ENV == 'production';
// Set up middleware parsers
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }));
// parse application/json
app.use(bodyParser.json());
app.use(cookieParser());
// Include static assets. Not advised for production
app.use(express.static(path.join(__dirname, '')));
// set up nunjucks for templating. You can use whatever
app.set('templates', path.join(__dirname, ''));
var env = nunjucks.configure(app.get('templates'), {
autoescape: false,
express: app
});
app.set('view engine', 'nunjucks');
// Set up Routes for the application
require('./routes/core-routes.js')(app);
//Route not found -- Set 404
app.get('*', function(req, res) {
res.json({
"route": "This page does not exist! Please turn around and go back!"
});
});
var port = process.env.PORT || 4444;
app.listen(port);
console.log('Server is Up and Running at Port : ' + port);