-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
38 lines (31 loc) · 1010 Bytes
/
server.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
37
38
const express = require("express");
const path = require("path");
const { spawn } = require("child_process");
const app = express();
const port = 8080;
// set up rate limiter: maximum of five requests per minute
var RateLimit = require("express-rate-limit");
var limiter = RateLimit({
windowMs: 1 * 60 * 1000, // 1 minute
max: 500,
});
app.use(limiter);
// Use body-parser
var bodyParser = require("body-parser");
// Define the JSON parser as a default way
// to consume and produce data through the
// exposed APIs
app.use(bodyParser.json());
// Create link to Angular build directory
// The `ng build` command will save the result
// under the `dist` folder.
var distDir = __dirname + "/public/thejoshieman.github.io/";
app.use(express.static(distDir));
function getRoot(request, response) {
response.sendFile(path.resolve(distDir + "index.html"));
}
app.get("/", getRoot);
app.listen(port, () =>
console.log(`Example app listening on port
${port}!`)
);