-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (30 loc) · 935 Bytes
/
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
// (c) Copyright Merative US L.P. and others 2020-2022
//
// SPDX-Licence-Identifier: Apache 2.0
const http = require('http');
const httpProxy = require('http-proxy');
const verifierConfig = require('./verifier-config.json');
const proxy = httpProxy.createProxyServer({});
const port = 3000
http.createServer(function (req, res) {
if (req.url.includes('/hpass/')) {
proxy.web(req, res, {
target: 'http://127.0.0.1:3010'
});
return;
}
if (req.url.includes('/verifier/')) {
res.setHeader("Content-Type", "application/json");
res.writeHead(200);
res.end(JSON.stringify(verifierConfig));
return;
}
if (req.url.includes('/metering/')) {
res.setHeader("Content-Type", "application/json");
res.writeHead(200);
res.end('ok');
return;
}
res.writeHead(404);
res.end('Route not found');
}).listen(port);