-
Notifications
You must be signed in to change notification settings - Fork 0
/
gw.js
32 lines (28 loc) · 910 Bytes
/
gw.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
const express = require('express');
const fs = require("fs");
const https = require("https");
const port = process.env.PORT || 8080;
const options = {
key: fs.readFileSync(`${__dirname}/certs/fed/gw-key.pem`),
cert: fs.readFileSync(`${__dirname}/certs/fed/gw-crt.pem`),
ca: [
fs.readFileSync(`${__dirname}/certs/fed/ca-crt.pem`)
],
// Requesting the client to provide a certificate, to authenticate.
requestCert: true,
// As specified as "true", so no unauthenticated traffic
// will make it to the specified route specified
rejectUnauthorized: true
};
// Load mock data
const data = JSON.parse(fs.readFileSync(__dirname + "/data/" + "data.json", 'utf8'));
const app = express();
app.get('/', function(req,res) {
res.send('"OK!');
});
app.get('/feds', function (req, res) {
res.end(JSON.stringify(data.federators, null, 2));
})
https
.createServer(options, app)
.listen(port);