forked from tesssapierce/BookShelf-Public-Library-Online-Rental-System-Javascript-Express-MySQL-Sequelize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
37 lines (30 loc) · 851 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
34
35
36
37
//Express
var express = require("express");
var app = express();
//Models
var db=require("./models");
//Server BS
var PORT = process.env.PORT || 8080;
app.use(express.static("public"));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
//Handlebars
var exphbs = require("express-handlebars");
const handlebarsConfig = {
defaultLayout: "main",
runtimeOptions: {
allowProtoPropertiesByDefault: true,
allowProtoMethodsByDefault: true
}
}
app.engine("handlebars", exphbs(handlebarsConfig));
app.set("view engine", "handlebars");
//Routes
require("./routes/html/htmlRoutes.js")(app);
require("./routes/api/apiRoutes.js")(app);
//Listener + Sequelize Sync
db.sequelize.sync({ force: false}).then(function() {
app.listen(PORT, function() {
console.log("App listening on PORT " + PORT);
});
});