-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
40 lines (31 loc) · 1.12 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
// Import dependencies.
var express = require('express');
var path = require('path');
var exphbs = require('express-handlebars');
var favicon = require('serve-favicon');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var db = require('./models');
// Initialize app.
var app = express();
// Serve static content for the app from the "public" directory in the application directory.
app.use(express.static(path.join(__dirname, 'public')));
var PORT = process.env.PORT || 3000;
// Set handlebars as view engine.
app.engine('handlebars', exphbs({ defaultLayout: 'main' }));
app.set('view engine', 'handlebars');
// Favicon
app.use(favicon(path.join(__dirname, 'public/assets/img', 'favicon.png')));
// Body Parser
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
// Method override.
app.use(methodOverride('_method'));
// Import routes and give the server access to them.
require('./controllers/controller.js')(app);
// Start listening.
db.sequelize.sync().then(function() {
app.listen(PORT, function() {
console.log('listening on port ' + PORT);
});
});