-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
33 lines (25 loc) · 898 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
'use strict';
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
var routes = require('./routes');
var swig = require('swig');
var morgan = require('morgan');
var path = require('path');
var port = process.env.PORT || 3000;
// Template Boilerplate
app.engine('html', swig.renderFile); // how to render html templates
app.set('view engine', 'html'); // what file extension do our templates have
app.set('views', path.join(__dirname, '/views')); // where to find the views
swig.setDefaults({ cache: false });
// Middleware
app.use(morgan('dev'));
// Body Parser Stuff
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use('/', routes);
app.listen(port, function() {
console.log('Listening on port ' + port);
});
app.use(express.static(path.join(__dirname, '/public')));