-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
61 lines (45 loc) · 2.35 KB
/
Copy pathserver.js
File metadata and controls
61 lines (45 loc) · 2.35 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// ==============================================================================
// DEPENDENCIES
// Series of npm packages that we will use to give our server useful functionality
// ==============================================================================
var express = require("express");
var bodyParser = require("body-parser");
var handleBars = require('handlebars');
var exphbs = require("express-handlebars");
//Note that the mysql dependency handled in the database layer
// ==============================================================================
// EXPRESS CONFIGURATION
// This sets up the basic properties for our express server
// ==============================================================================
// Tells node that we are creating an "express" server
var app = express();
//Static directory to serve css etc
app.use(express.static('public'));
// Sets up the Express app to handle data parsing
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json({type:'application/vnd.api+json'}));
// ================================================================================
// Handlebars
// Templating Functions will be handled by handlebars
// I thought this was similar to Razor, but razor is really a scripting languate
// handleBards is really a template. Comparable (a little) to partialViews
// But not really :-(
// ================================================================================
app.engine("handlebars", exphbs({ defaultLayout: "main" }));
app.set("view engine", "handlebars");
// ================================================================================
// ROUTER
// The below points our server to a series of "route" files.
// These routes give our server a "map" of how to respond when users visit or request data from various URLs.
// ================================================================================
var routes = require("./controllers/burgers_controller.js");
app.use(routes);
// =============================================================================
// LISTENER
// The below code effectively "starts" our server
// =============================================================================
// Sets an initial port. We"ll use this later in our listener
var PORT = process.env.PORT || 8082;
app.listen(PORT, function() {
console.log("App listening on PORT: " + PORT);
});