Browse Source

refactor: extract host protocol to env vars

develop
Apostolos Fanakis 4 years ago
parent
commit
cbbdb8c4d1
  1. 2
      packages/concordia-app/src/utils/drizzleUtils.js
  2. 7
      packages/concordia-contracts-provider/src/constants.js
  3. 2
      packages/concordia-contracts/utils/contractsProviderUtils.js
  4. 2
      packages/concordia-pinner/src/utils/drizzleUtils.js
  5. 4
      packages/concordia-pinner/src/utils/ipfsUtils.js
  6. 2
      packages/concordia-shared/src/configuration/breezeConfiguration.js
  7. 10
      packages/concordia-shared/src/constants/configuration/defaults.js
  8. 5
      packages/concordia-shared/src/utils/rendezvous.js

2
packages/concordia-app/src/utils/drizzleUtils.js

@ -20,7 +20,7 @@ function getContractsDownloadRequest() {
const xhrRequest = new XMLHttpRequest(); const xhrRequest = new XMLHttpRequest();
xhrRequest.open('GET', xhrRequest.open('GET',
`http://${contractsProviderHost}:${contractsProviderPort}/contracts/${contractsVersionHash}`, `${contractsProviderHost}:${contractsProviderPort}/contracts/${contractsVersionHash}`,
false); false);
xhrRequest.setRequestHeader('Access-Control-Allow-Origin', `${HOST}:${PORT}`); xhrRequest.setRequestHeader('Access-Control-Allow-Origin', `${HOST}:${PORT}`);
xhrRequest.setRequestHeader('Access-Control-Allow-Credentials', 'true'); xhrRequest.setRequestHeader('Access-Control-Allow-Credentials', 'true');

7
packages/concordia-contracts-provider/src/constants.js

@ -1,7 +1,12 @@
import path from 'path'; import path from 'path';
const UPLOAD_CONTRACTS_DIRECTORY = path.join(__dirname, '..', 'contracts-uploads'); const UPLOAD_CONTRACTS_DIRECTORY = path.join(__dirname, '..', 'contracts-uploads');
const CORS_ALLOWED_ORIGINS = ['http://127.0.0.1:7000', 'http://localhost:7000']; const CORS_ALLOWED_ORIGINS = [
'http://127.0.0.1:7000', 'http://localhost:7000',
'https://127.0.0.1:7000', 'https://localhost:7000',
'http://127.0.0.1:4444', 'http://localhost:4444',
'https://127.0.0.1:4444', 'https://localhost:4444',
];
const LOGS_PATH = path.join(__dirname, '..', 'logs'); const LOGS_PATH = path.join(__dirname, '..', 'logs');
export default { export default {

2
packages/concordia-contracts/utils/contractsProviderUtils.js

@ -5,7 +5,7 @@ const { contractsProviderPort } = require('concordia-shared/src/environment/inte
const { contracts } = require('../index'); const { contracts } = require('../index');
const uploadContractsToProviderUnirest = (versionHash, tag) => { const uploadContractsToProviderUnirest = (versionHash, tag) => {
const uploadPath = `http://${contractsProviderHost}:${contractsProviderPort}/contracts/${versionHash}`; const uploadPath = `${contractsProviderHost}:${contractsProviderPort}/contracts/${versionHash}`;
const request = unirest('POST', uploadPath) const request = unirest('POST', uploadPath)
.field('tag', tag); .field('tag', tag);

2
packages/concordia-pinner/src/utils/drizzleUtils.js

@ -12,7 +12,7 @@ function getContractsDownloadRequest() {
const HOST = pinnerApiHost; const HOST = pinnerApiHost;
const PORT = pinnerApiPort; const PORT = pinnerApiPort;
const contractsProviderAddress = `http://${contractsProviderHost}:${contractsProviderPort}/contracts/` const contractsProviderAddress = `${contractsProviderHost}:${contractsProviderPort}/contracts/`
+ `${contractsVersionHash}`; + `${contractsVersionHash}`;
const selfAddress = `${HOST}:${PORT}`; const selfAddress = `${HOST}:${PORT}`;

4
packages/concordia-pinner/src/utils/ipfsUtils.js

@ -9,4 +9,6 @@ export const getResolvedRendezvousUrl = async () => dnsLookup(rendezvousHost, {
.catch((error) => logger.error(new Error(`DNS lookup of ${rendezvousHost} failed.\n${error}`))); .catch((error) => logger.error(new Error(`DNS lookup of ${rendezvousHost} failed.\n${error}`)));
export const getSwarmAddresses = async () => getResolvedRendezvousUrl() export const getSwarmAddresses = async () => getResolvedRendezvousUrl()
.then((resolvedRendezvousUrl) => [`/ip4/${resolvedRendezvousUrl.address}/tcp/${rendezvousPort}/wss/p2p-webrtc-star`]); .then((resolvedRendezvousUrl) => [
`${resolvedRendezvousUrl.address}/tcp/${rendezvousPort}/wss/p2p-webrtc-star`,
]);

2
packages/concordia-shared/src/configuration/breezeConfiguration.js

@ -9,7 +9,7 @@ const getBreezeConfiguration = (identityProvider) => ({
Swarm: [ Swarm: [
// Use local signaling server (see also rendezvous script in package.json) // Use local signaling server (see also rendezvous script in package.json)
// For more information: https://github.com/libp2p/js-libp2p-webrtc-star // For more information: https://github.com/libp2p/js-libp2p-webrtc-star
`/ip4/${rendezvousHost}/tcp/${rendezvousPort}/wss/p2p-webrtc-star`, `${rendezvousHost}/tcp/${rendezvousPort}/wss/p2p-webrtc-star`,
// Use the following public servers if needed // Use the following public servers if needed
// '/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star', // '/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star',

10
packages/concordia-shared/src/constants/configuration/defaults.js

@ -1,20 +1,20 @@
// Contracts provider // Contracts provider
const CONTRACTS_PROVIDER_HOST_DEFAULT = '127.0.0.1'; const CONTRACTS_PROVIDER_HOST_DEFAULT = 'http://127.0.0.1';
const CONTRACTS_PROVIDER_PORT_DEFAULT = '8400'; const CONTRACTS_PROVIDER_PORT_DEFAULT = '8400';
const CONTRACTS_VERSION_HASH_DEFAULT = 'latest'; const CONTRACTS_VERSION_HASH_DEFAULT = 'latest';
// Pinner // Pinner
const PINNER_API_HOST_DEFAULT = '127.0.0.1'; const PINNER_API_HOST_DEFAULT = 'http://127.0.0.1';
const PINNER_API_PORT_DEFAULT = 4444; const PINNER_API_PORT_DEFAULT = 4444;
// Rendezvous // Rendezvous
const RENDEZVOUS_HOST_DEFAULT = '127.0.0.1'; const RENDEZVOUS_HOST_DEFAULT = '/ip4/127.0.0.1';
const RENDEZVOUS_PORT_DEFAULT = '9090'; const RENDEZVOUS_PORT_DEFAULT = '9090';
// Web3 (probably ganache) // Web3 (probably ganache)
const WEB3_HOST_DEFAULT = '127.0.0.1'; const WEB3_HOST_DEFAULT = 'http://127.0.0.1';
const WEB3_PORT_DEFAULT = '8545'; const WEB3_PORT_DEFAULT = '8545';
const WEB3_HOST_TEST_DEFAULT = '127.0.0.1'; const WEB3_HOST_TEST_DEFAULT = 'http://127.0.0.1';
const WEB3_PORT_TEST_DEFAULT = '8546'; const WEB3_PORT_TEST_DEFAULT = '8546';
const WEB3_PORT_SOCKET_TIMEOUT_DEFAULT = 30000; const WEB3_PORT_SOCKET_TIMEOUT_DEFAULT = 30000;
const WEB3_PORT_SOCKET_CONNECT_MAX_ATTEMPTS_DEFAULT = 3; const WEB3_PORT_SOCKET_CONNECT_MAX_ATTEMPTS_DEFAULT = 3;

5
packages/concordia-shared/src/utils/rendezvous.js

@ -1,5 +0,0 @@
const { rendezvousHost, rendezvousPort } = require('../environment/interpolated/rendezvous');
const getRendezvousUrl = () => `http://${rendezvousHost}:${rendezvousPort}`;
module.exports = getRendezvousUrl;
Loading…
Cancel
Save