-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (25 loc) · 1.01 KB
/
Copy pathserver.js
File metadata and controls
37 lines (25 loc) · 1.01 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
// DEPENDENCIES
// packages that we will use to give our server useful functionality
const path = require("path");
const bodyParser = require("body-parser");
const express = require("express");
// EXPRESS
// This sets up the basic properties for our express server
// Tells node that we are creating an "express" server
const app = express();
// Sets an initial port. We"ll use this later in our listener
let PORT = process.env.PORT || 3000;
// Sets up the Express app to handle data parsing
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
let data = require("./app/data/friends.js");
// ROUTER
// The below points 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.
require("./app/routing/apiRoutes")(app, data);
require("./app/routing/htmlRoutes")(app, path);
// LISTENER
// The below code effectively "starts" the server
app.listen(PORT, function(){
console.log("App listening on PORT" + PORT);
})