-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
42 lines (30 loc) · 1.25 KB
/
server.js
File metadata and controls
42 lines (30 loc) · 1.25 KB
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
// =============================================================
// Dependencies
// =============================================================
var express = require("express");
var handlebars = require("express-handlebars");
var app = express();
// added PORT to either be assigned by HEROKU or default to 8080
var PORT = process.env.PORT || 8080;
// Requiring the models for syncing
var db = require("./models");
// added the ./ static to allow the image to show
app.use(express.static("./"));
// the public folder static is needed for the css styling
app.use(express.static("public"));
// use the appropriate middleware
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
// set the express app to use handlebars
app.engine("handlebars", handlebars({ defaultLayout: "main" }));
app.set("view engine", "handlebars");
// require the controller files
require("./controllers/burgers_controller.js")(app);
require("./controllers/customers_controller.js")(app);
// Syncing the sequelize models and then start the Express app
// =============================================================
db.sequelize.sync({ force: false }).then(function() {
app.listen(PORT, function() {
console.log("App listening on PORT " + PORT);
});
});