-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
36 lines (25 loc) · 1.02 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
let express = require("express");
let app = express();
// Set the port of the application
// process.env.PORT lets the port be set by Heroku
let PORT = process.env.PORT || 8080;
let db = require("./models");
// Serve static content for the app from the "public" directory in the application directory.
app.use(express.static("public"));
// Parse request body as JSON
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
let exphbs = require("express-handlebars");
app.engine("handlebars", exphbs({ defaultLayout: "main" }));
app.set("view engine", "handlebars");
// Import routes and give the server access to them.
// let routes = require("./routes/api-routes.js")(app);
// app.use(routes);
require("./routes/api-routes.js")(app);
// Syncing our sequelize models and then starting our Express app
// =============================================================
db.sequelize.sync({ force: true }).then(function() {
app.listen(PORT, function() {
console.log("App listening on PORT " + PORT);
});
});