-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
33 lines (25 loc) · 819 Bytes
/
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
var express = require("express")
var bodyParser = require("body-parser");
// Initialize Express
var app = express();
var PORT = process.env.PORT || 3000;
// Sequelize database import
var db = require("./models");
// Use the public folder
app.use(express.static("public"));
// Initialize body parser
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
// Initialize handlebars
var exphbs = require("express-handlebars");
app.engine("handlebars", exphbs({ defaultLayout: "main" }));
app.set("view engine", "handlebars");
// Initialize the routing file
app.use(express.static("public"));
require("./routes/api-routes.js")(app);
// Start the server
db.sequelize.sync().then(function() {
app.listen(PORT, function() {
console.log("App listening on PORT " + PORT);
});
});