@mimik/configuration 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/index.js +23 -8
- package/lib/common.js +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,9 +43,10 @@ The following environment variables are being setup:
|
|
|
43
43
|
| SERVER_VERSION | version of the software for the micro-service | package.version | serverSettings.version
|
|
44
44
|
| SERVER_NAME | name of the micro-service | package.name | serverSettings.name
|
|
45
45
|
| SERVER_TYPE | type of the micro-service | package.mimik.type | serverSettings.type
|
|
46
|
-
| SWAGGER_FILE_VERSION | version of the swagger file for the API | package.swaggerFile.version | serverSettings.
|
|
47
|
-
| SWAGGER_FILE_ACCOUNT | account associated with the API | package.swaggerFile.account |
|
|
48
|
-
| SWAGGER_FILE_NAME | name of the API | package.swaggerFile.name |
|
|
46
|
+
| SWAGGER_FILE_VERSION | version of the swagger file for the API | package.swaggerFile.version | serverSettings.swaggerFile.version
|
|
47
|
+
| SWAGGER_FILE_ACCOUNT | account associated with the API | package.swaggerFile.account | serverSettings.swaggerFile.account
|
|
48
|
+
| SWAGGER_FILE_NAME | name of the API | package.swaggerFile.name | serverSettings.swaggerFile.name
|
|
49
|
+
| SWAGGER_FILE_PROVIDER | provider of the API file | package.swaggerFile.provider | serverSettings.swaggerFile.provider, if not present the default is `bitbucket`
|
|
49
50
|
| SERVER_LOCAL_IPV4 | IP address of the micro-service | ip.address() | serverSettings.ip.local
|
|
50
51
|
| CONSOLE_LEVEL | log level for console output | debug | logInfo.consoleLevel
|
|
51
52
|
| LOG_LEVEL | log level for console output | debug | logInfo.logLevel
|
|
@@ -63,8 +64,8 @@ The following environement variables are being used for the configuration:
|
|
|
63
64
|
| SERVER_ID | service id | uuid.v4() | serverSettings.id |
|
|
64
65
|
| CUSTOMER_CODE | customer code associated with the service instance | '' | serverSettings.customerCode | empty string
|
|
65
66
|
| SWAGGER_FILE_DIRECTORY | directory where the api definition is located | ./api | serverSettings.api | [1]
|
|
66
|
-
| BITBUCKET_USERNAME | username to access bitbucket read access on the swagger repos | | serverSettings.apiBasicAuth.username
|
|
67
|
-
| BITBUCKET_PASSWORD | password to access bitbucket read access on the swagger repos | | serverSettings.apiBasicAuth.password
|
|
67
|
+
| BITBUCKET_USERNAME | username to access bitbucket read access on the swagger repos | ' ' | serverSettings.apiBasicAuth.username
|
|
68
|
+
| BITBUCKET_PASSWORD | password to access bitbucket read access on the swagger repos | ' ' | serverSettings.apiBasicAuth.password
|
|
68
69
|
| SERVER_SECURITY_SET | switch to enable or disable the token interpretation | on | serverSettings.securitySet | only active if environment is `local`
|
|
69
70
|
| INTERCEPT_ERROR | switch to use or not the errorIntercept option | on | serverSettings.interceptError | must be set to off for mID
|
|
70
71
|
| SERVER_PORT | port of the server | | serverSettings.port |
|
package/index.js
CHANGED
|
@@ -87,7 +87,11 @@ const {
|
|
|
87
87
|
DEFAULT_SERVER_PUBLIC_DOMAIN_NAME,
|
|
88
88
|
DEFAULT_ADMIN_EXTERNAL_ID,
|
|
89
89
|
DEFAULT_SWAGGER_DIR,
|
|
90
|
+
DEFAULT_SWAGGER_FILE_PROVIDER,
|
|
91
|
+
SUPPORTED_SWAGGER_FILE_PROVIDERS,
|
|
90
92
|
DEFAULT_INTERCEPT_ERROR,
|
|
93
|
+
DEFAULT_BITBUCKET_USERNAME,
|
|
94
|
+
DEFAULT_BITBUCKET_PASSWORD,
|
|
91
95
|
} = require('./lib/common');
|
|
92
96
|
|
|
93
97
|
let display = true;
|
|
@@ -444,8 +448,8 @@ if (!isMSTSet) {
|
|
|
444
448
|
if (process.env.OAUTH_GENERIC_PREVIOUS_KEY) configuration.security.generic.previousKey = process.env.OAUTH_GENERIC_PREVIOUS_KEY;
|
|
445
449
|
if (process.env.BITBUCKET_USERNAME) {
|
|
446
450
|
configuration.serverSettings.apiBasicAuth = {
|
|
447
|
-
username: process.env.BITBUCKET_USERNAME,
|
|
448
|
-
password: process.env.BITBUCKET_PASSWORD,
|
|
451
|
+
username: process.env.BITBUCKET_USERNAME || DEFAULT_BITBUCKET_USERNAME,
|
|
452
|
+
password: process.env.BITBUCKET_PASSWORD || DEFAULT_BITBUCKET_PASSWORD,
|
|
449
453
|
};
|
|
450
454
|
}
|
|
451
455
|
configuration.logInfo = setupLog();
|
|
@@ -470,9 +474,10 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
470
474
|
* | SERVER_VERSION | version of the software for the micro-service | package.version | serverSettings.version
|
|
471
475
|
* | SERVER_NAME | name of the micro-service | package.name | serverSettings.name
|
|
472
476
|
* | SERVER_TYPE | type of the micro-service | package.mimik.type | serverSettings.type
|
|
473
|
-
* | SWAGGER_FILE_VERSION | version of the swagger file for the API | package.swaggerFile.version | serverSettings.
|
|
474
|
-
* | SWAGGER_FILE_ACCOUNT | account associated with the API | package.swaggerFile.account |
|
|
475
|
-
* | SWAGGER_FILE_NAME | name of the API | package.swaggerFile.name |
|
|
477
|
+
* | SWAGGER_FILE_VERSION | version of the swagger file for the API | package.swaggerFile.version | serverSettings.swaggerFile.version
|
|
478
|
+
* | SWAGGER_FILE_ACCOUNT | account associated with the API | package.swaggerFile.account | serverSettings.swaggerFile.account
|
|
479
|
+
* | SWAGGER_FILE_NAME | name of the API | package.swaggerFile.name | serverSettings.swaggerFile.name
|
|
480
|
+
* | SWAGGER_FILE_PROVIDER | provider of the API file | package.swaggerFile.provider | serverSettings.swaggerFile.provider, if not present the default is `bitbucket`
|
|
476
481
|
* | SERVER_LOCAL_IPV4 | IP address of the micro-service | ip.address() | serverSettings.ip.local
|
|
477
482
|
* | CONSOLE_LEVEL | log level for console output | debug | logInfo.consoleLevel
|
|
478
483
|
* | LOG_LEVEL | log level for console output | debug | logInfo.logLevel
|
|
@@ -490,8 +495,8 @@ configuration.locationProvider = setupLocationProvider();
|
|
|
490
495
|
* | SERVER_ID | service id | uuid.v4() | serverSettings.id |
|
|
491
496
|
* | CUSTOMER_CODE | customer code associated with the service instance | '' | serverSettings.customerCode | empty string
|
|
492
497
|
* | SWAGGER_FILE_DIRECTORY | directory where the api definition is located | ./api | serverSettings.api | [1]
|
|
493
|
-
* | BITBUCKET_USERNAME | username to access bitbucket read access on the swagger repos | | serverSettings.apiBasicAuth.username
|
|
494
|
-
* | BITBUCKET_PASSWORD | password to access bitbucket read access on the swagger repos | | serverSettings.apiBasicAuth.password
|
|
498
|
+
* | BITBUCKET_USERNAME | username to access bitbucket read access on the swagger repos | ' ' | serverSettings.apiBasicAuth.username
|
|
499
|
+
* | BITBUCKET_PASSWORD | password to access bitbucket read access on the swagger repos | ' ' | serverSettings.apiBasicAuth.password
|
|
495
500
|
* | SERVER_SECURITY_SET | switch to enable or disable the token interpretation | on | serverSettings.securitySet | only active if environment is `local`
|
|
496
501
|
* | INTERCEPT_ERROR | switch to use or not the errorIntercept option | on | serverSettings.interceptError | must be set to off for mID
|
|
497
502
|
* | SERVER_PORT | port of the server | | serverSettings.port |
|
|
@@ -641,6 +646,8 @@ const setConfig = (pack, options) => {
|
|
|
641
646
|
process.env.SWAGGER_FILE_VERSION = pack.swaggerFile.version;
|
|
642
647
|
process.env.SWAGGER_FILE_ACCOUNT = pack.swaggerFile.account;
|
|
643
648
|
process.env.SWAGGER_FILE_NAME = pack.swaggerFile.name;
|
|
649
|
+
if (pack.swaggerFile.provider) process.env.SWAGGER_FILE_PROVIDER = pack.swaggerFile.provider;
|
|
650
|
+
else process.env.SWAGGER_FILE_PROVIDER = DEFAULT_SWAGGER_FILE_PROVIDER;
|
|
644
651
|
}
|
|
645
652
|
|
|
646
653
|
// eslint-disable-next-line max-len
|
|
@@ -650,7 +657,12 @@ const setConfig = (pack, options) => {
|
|
|
650
657
|
configuration.serverSettings.type = process.env.SERVER_TYPE;
|
|
651
658
|
configuration.serverSettings.version = process.env.SERVER_VERSION;
|
|
652
659
|
configuration.serverSettings.api = `${process.env.SWAGGER_FILE_DIRECTORY || DEFAULT_SWAGGER_DIR}/${apiFilename}`;
|
|
653
|
-
configuration.serverSettings.
|
|
660
|
+
configuration.serverSettings.swaggerFile = {
|
|
661
|
+
version: process.env.SWAGGER_FILE_VERSION,
|
|
662
|
+
name: process.env.SWAGGER_FILE_NAME,
|
|
663
|
+
account: process.env.SWAGGER_FILE_ACCOUNT,
|
|
664
|
+
provider: process.env.SWAGGER_FILE_PROVIDER,
|
|
665
|
+
};
|
|
654
666
|
|
|
655
667
|
// default for every server for cluster management
|
|
656
668
|
configuration.dependencies[configuration.serverSettings.type] = {
|
|
@@ -659,6 +671,9 @@ const setConfig = (pack, options) => {
|
|
|
659
671
|
|
|
660
672
|
if (isMSTSet) configuration.dependencies[configuration.serverSettings.type].audience = process.env[`${configuration.serverSettings.type}_AUDIENCE`.toUpperCase()];
|
|
661
673
|
|
|
674
|
+
if (!SUPPORTED_SWAGGER_FILE_PROVIDERS.includes(configuration.serverSettings.swaggerFile.provider)) {
|
|
675
|
+
throw new Error(`swaggerFile provider not supported: ${configuration.serverSettings.swaggerFile.provider}`);
|
|
676
|
+
}
|
|
662
677
|
if (options.database) {
|
|
663
678
|
if (options.database.type === 'mongodb') {
|
|
664
679
|
configuration.mongoSettings = setupMongo(options.database);
|
package/lib/common.js
CHANGED
|
@@ -88,6 +88,11 @@ const DEFAULT_SERVER_PUBLIC_DOMAIN_NAME = null;
|
|
|
88
88
|
const DEFAULT_ADMIN_EXTERNAL_ID = 'admin';
|
|
89
89
|
|
|
90
90
|
const DEFAULT_SWAGGER_DIR = '../api';
|
|
91
|
+
const DEFAULT_SWAGGER_FILE_PROVIDER = 'bitbucket';
|
|
92
|
+
const SUPPORTED_SWAGGER_FILE_PROVIDERS = [DEFAULT_SWAGGER_FILE_PROVIDER, 'swaggger'];
|
|
93
|
+
|
|
94
|
+
const DEFAULT_BITBUCKET_USERNAME = ' ';
|
|
95
|
+
const DEFAULT_BITBUCKET_PASSWORD = ' ';
|
|
91
96
|
|
|
92
97
|
module.exports = {
|
|
93
98
|
SUMOLOGIC,
|
|
@@ -162,5 +167,9 @@ module.exports = {
|
|
|
162
167
|
DEFAULT_SERVER_PUBLIC_DOMAIN_NAME,
|
|
163
168
|
DEFAULT_ADMIN_EXTERNAL_ID,
|
|
164
169
|
DEFAULT_SWAGGER_DIR,
|
|
170
|
+
DEFAULT_SWAGGER_FILE_PROVIDER,
|
|
171
|
+
SUPPORTED_SWAGGER_FILE_PROVIDERS,
|
|
165
172
|
DEFAULT_INTERCEPT_ERROR,
|
|
173
|
+
DEFAULT_BITBUCKET_USERNAME,
|
|
174
|
+
DEFAULT_BITBUCKET_PASSWORD,
|
|
166
175
|
};
|