Skip to content

Commit

Permalink
fix: make management url config option optional (#310)
Browse files Browse the repository at this point in the history
* fix: make management url config option optional

* chore: spelling
  • Loading branch information
kleyow authored Apr 22, 2022
1 parent 0b0e249 commit 93c4048
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ ALLOW_TRANSFER_WITHOUT_QUOTE=false
# To enable request for notification on fulfiled transfer
RESERVE_NOTIFICATION=true

# resources API versions should be string in format: "resouceOneName=1.0,resourceTwoName=1.1"
# resources API versions should be string in format: "resourceOneName=1.0,resourceTwoName=1.1"
RESOURCE_VERSIONS="transfers=1.1,participants=1.1"

# Management API websocket connection settings.
Expand Down
16 changes: 8 additions & 8 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ function getFileContent (path) {
}

/**
* Gets Resources versions from enviromental variable RESOURCES_VERSIONS
* should be string in format: "resouceOneName=1.0,resourceTwoName=1.1"
* Gets Resources versions from environmental variable RESOURCES_VERSIONS
* should be string in format: "resourceOneName=1.0,resourceTwoName=1.1"
*/
function getVersionFromConfig (resourceString) {
const resourceVersionMap = {};
Expand All @@ -44,7 +44,7 @@ function parseResourceVersions (resourceString) {
const resourceFormatRegex = /(([A-Za-z])\w*)=([0-9]+).([0-9]+)([^;:|],*)/g;
const noSpResources = resourceString.replace(/\s/g,'');
if (!resourceFormatRegex.test(noSpResources)) {
throw new Error('Resource versions format should be in format: "resouceOneName=1.0,resourceTwoName=1.1"');
throw new Error('Resource versions format should be in format: "resourceOneName=1.0,resourceTwoName=1.1"');
}
return getVersionFromConfig(noSpResources);
}
Expand All @@ -58,10 +58,6 @@ const env = from(process.env, {

module.exports = {
__parseResourceVersion: parseResourceVersions,
control: {
mgmtAPIWsUrl: env.get('MGMT_API_WS_URL').required().asString(),
mgmtAPIWsPort: env.get('MGMT_API_WS_PORT').default('4005').asPortNumber()
},
mutualTLS: {
inboundRequests: {
enabled: env.get('INBOUND_MUTUAL_TLS_ENABLED').default('false').asBool(),
Expand Down Expand Up @@ -157,7 +153,7 @@ module.exports = {

proxyConfig: env.get('PROXY_CONFIG_PATH').asYamlConfig(),
reserveNotification: env.get('RESERVE_NOTIFICATION').default('false').asBool(),
// resourceVersions config should be string in format: "resouceOneName=1.0,resourceTwoName=1.1"
// resourceVersions config should be string in format: "resourceOneName=1.0,resourceTwoName=1.1"
resourceVersions: env.get('RESOURCE_VERSIONS').default('').asResourceVersions(),

// in 3PPI DFSP's generate their own `transferId` which is associated with
Expand All @@ -166,4 +162,8 @@ module.exports = {
allowDifferentTransferTransactionId: env.get('ALLOW_DIFFERENT_TRANSFER_TRANSACTION_ID').default('false').asBool(),

pm4mlEnabled: env.get('PM4ML_ENABLED').default('false').asBool(),
control: {
mgmtAPIWsUrl: env.get('MGMT_API_WS_URL').default('127.0.0.1').asString(),
mgmtAPIWsPort: env.get('MGMT_API_WS_PORT').default('4005').asPortNumber()
},
};
2 changes: 1 addition & 1 deletion test/unit/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('config', () => {

it('should throw an err if the resource string is not correctly formed', () => {
const parseResourceVersion = require('~/config').__parseResourceVersion;
expect(() => parseResourceVersion('resourceOneName=1.0;resourceTwoName=1.1')).toThrowError(new Error('Resource versions format should be in format: "resouceOneName=1.0,resourceTwoName=1.1"'));
expect(() => parseResourceVersion('resourceOneName=1.0;resourceTwoName=1.1')).toThrowError(new Error('Resource versions format should be in format: "resourceOneName=1.0,resourceTwoName=1.1"'));
});

});

0 comments on commit 93c4048

Please sign in to comment.