Browse Source

add parameter binding the apis to a given host

use-env-var-docker
kenshin-samourai 5 years ago
parent
commit
afc2bc3b26
  1. 3
      accounts/index.js
  2. 4
      docker/my-dojo/node/keys.index.js
  3. 5
      keys/index-example.js
  4. 10
      lib/http-server/http-server.js
  5. 3
      pushtx/index.js
  6. 3
      tracker/index.js

3
accounts/index.js

@ -52,8 +52,9 @@
hdaHelper.activateExternalDerivation()
// Initialize the http server
const host = keys.apiBind
const port = keys.ports.account
const httpServer = new HttpServer(port)
const httpServer = new HttpServer(port, host)
// Initialize the rest api endpoints
const authRestApi = new AuthRestApi(httpServer)

4
docker/my-dojo/node/keys.index.js

@ -64,6 +64,10 @@ module.exports = {
connectionLimitPushTxApi: 5,
connectionLimitPushTxOrchestrator: 5
},
/*
* IP address used to expose the API ports
*/
apiBind: '0.0.0.0',
/*
* TCP Ports
*/

5
keys/index-example.js

@ -61,6 +61,10 @@ module.exports = {
connectionLimitPushTxApi: 5,
connectionLimitPushTxOrchestrator: 5
},
/*
* IP address used to expose the API ports
*/
apiBind: '127.0.0.1',
/*
* TCP Ports
*/
@ -240,6 +244,7 @@ module.exports = {
connectionLimitPushTxApi: 1,
connectionLimitPushTxOrchestrator: 5
},
apiBind: '127.0.0.1',
ports: {
account: 18080,
pushtx: 18081,

10
lib/http-server/http-server.js

@ -18,9 +18,11 @@ class HttpServer {
/**
* Constructor
* @param {int} port - port used by the http server
* @param {string} host - host exposing the http server
*/
constructor(port) {
// Initialize server port
constructor(port, host) {
// Initialize server host and port
this.host = host ? host : '127.0.0.1'
this.port = port
// Listening server instance
@ -54,8 +56,8 @@ class HttpServer {
})
// Start a http server
this.server = this.app.listen(this.port, () => {
Logger.info('HTTP server listening on port ' + this.port)
this.server = this.app.listen(this.port, this.host, () => {
Logger.info(`HTTP server listening on ${this.host}:${this.port}`)
})
this.server.timeout = 600 * 1000

3
pushtx/index.js

@ -44,8 +44,9 @@
})
// Initialize the http server
const host = keys.apiBind
const port = keys.ports.pushtx
const httpServer = new HttpServer(port)
const httpServer = new HttpServer(port, host)
// Initialize the PushTx rest api
const pushtxRestApi = new PushTxRestApi(httpServer)

3
tracker/index.js

@ -39,8 +39,9 @@
const tracker = new Tracker()
// Initialize the http server
const host = keys.apiBind
const port = keys.ports.trackerApi
const httpServer = new HttpServer(port)
const httpServer = new HttpServer(port, host)
// Initialize the rest api endpoints
const trackerRestApi = new TrackerRestApi(httpServer, tracker)

Loading…
Cancel
Save