-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
44 lines (33 loc) · 1.37 KB
/
Copy pathserver.js
File metadata and controls
44 lines (33 loc) · 1.37 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
43
44
// Solution 2: Customer Relations
// ===========================================
// Step 1: Created a Customer model in ./models/customer.js
// Step 2: Updated the Burger model to have a hasOne(models.Customer) relation
// Step 3: Updated the handlebars to display a customers name if there's a 'Customers' property on the Burger
// Step 4: Updated queries in burgerController for updating a burger to add the CustomerId
// Step 5: Updated findAll query in burger_controller for burgers to "include" the customer
// Step 6: Updated findAll query in burger_controller to order returned burgers by burger_name.
var express = require("express");
var bodyParser = require("body-parser");
// bring in the models
var db = require("./models");
var app = express();
// Serve static content for the app from the "public" directory in the application directory.
app.use(express.static("public"));
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({
extended: false
}));
var exphbs = require("express-handlebars");
app.engine("handlebars", exphbs({
defaultLayout: "main"
}));
app.set("view engine", "handlebars");
var routes = require("./controllers/burgers_controller");
app.use(routes);
// listen on port 3000
var PORT = process.env.PORT || 3000;
db.sequelize.sync().then(function() {
app.listen(PORT, function() {
console.log("App listening on PORT " + PORT);
});
});