-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
47 lines (37 loc) · 1.34 KB
/
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
45
46
47
'use strict';
var express = require('express');
var app = express();
var morgan = require('morgan');
var nunjucks = require('nunjucks');
var routes = require('./routes/');
// var fs = require('fs');
var path = require('path');
// var mime = require('mime');
var bodyParser = require('body-parser');
// var socketio = require('socket.io');
var models = require('./models');
// templating boilerplate setup
app.engine('html', nunjucks.render); // how to render html templates
app.set('view engine', 'html'); // what file extension do our templates have
nunjucks.configure('views', { noCache: true }); // where to find the views, caching off
// logging middleware
app.use(morgan('dev'));
// body parsing middleware
app.use(bodyParser.urlencoded({ extended: true })); // for HTML form submits
app.use(bodyParser.json()); // would be for AJAX requests
models.db.sync()
.then(function () {
// make sure to replace the name below with your express app
var server = app.listen(3000, function () {
console.log('Server is listening on port 3000!');
});
})
.catch(console.error);
// start the server
// var server = app.listen(1337, function(){
// console.log('listening on port 1337');
// });
//var io = socketio.listen(server);
app.use(express.static(path.join(__dirname, '/public')));
// modular routing that uses io inside it
app.use('/', routes);