-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (25 loc) · 1.12 KB
/
index.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
// ./index.js
// * Imports
const express = require("express"); // Imports Express's class definition
const morgan = require("morgan"); // Imports Morgan's class definition
// Imports from our class modules
const Blockchain = require("./src/blockchain");
// Global variables
global.difficulty = 5; // Difficulty to mine a particular block
global.blockchain = new Blockchain(); // Our copy of the blockchain
global.transactions = []; // Our current transactions
// Initialize express's class object
const app = express();
// Tell Express to use Morgan for logging requests to the console
app.use(morgan("dev")); // Pretty-print requests with the "dev" format
// Create the port number for the server to listen on
const port = 8080; // See: Wikipedia's List of TCP and UDP port numbers
// Tell Express to use the public directory for static files
app.use(express.static("public"));
// Dynamically load all routes from the ./routes folder
require("./routes")(app);
// Configure our server to run
app.listen(port, () => {
// Log that our server is running in the terminal
console.log(`Server is listening at http://localhost:${port}/`);
});