-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver.js
48 lines (39 loc) · 1.14 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
41
42
43
44
45
46
47
48
// Dependencies
const express = require("express");
// eslint-disable-next-line no-unused-vars
const routes = require("./routes/api-routes.js");
const syncOptions = { force: false };
// Sets up the Express App
const app = express();
const PORT = process.env.PORT || 8080;
// Requiring our models for syncing
const db = require("./models");
// Sets up the Express app to handle data parsing
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
// Static directory
app.use(express.static("public"));
const exphbs = require("express-handlebars");
app.engine(
"handlebars",
exphbs({
defaultLayout: "main",
runtimeOptions: {
allowProtoPropertiesByDefault: true,
allowProtoMethodsByDefault: true
}
})
);
app.set("view engine", "handlebars");
// Routes
require("./routes/api-routes.js")(app);
require("./routes/watch-api-routes.js")(app);
// if (process.env.NODE_ENV = "test"){
// syncOptions.force = true;
// }
// Syncing our sequelize models and then starting our Express app
db.sequelize.sync(syncOptions).then(() => {
app.listen(PORT, () => {
console.log("App listening on PORT " + PORT);
});
});