@mimik/configuration 5.0.1 → 5.0.3

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 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.swaggerFileVersion
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
@@ -65,6 +66,7 @@ The following environement variables are being used for the configuration:
65
66
  | SWAGGER_FILE_DIRECTORY | directory where the api definition is located | ./api | serverSettings.api | [1]
66
67
  | BITBUCKET_USERNAME | username to access bitbucket read access on the swagger repos | ' ' | serverSettings.apiBasicAuth.username
67
68
  | BITBUCKET_PASSWORD | password to access bitbucket read access on the swagger repos | ' ' | serverSettings.apiBasicAuth.password
69
+ | SWAGGERHUB_API_KEY | apiKey to access swaggerhub | | serverSettings.apiApiKey
68
70
  | SERVER_SECURITY_SET | switch to enable or disable the token interpretation | on | serverSettings.securitySet | only active if environment is `local`
69
71
  | INTERCEPT_ERROR | switch to use or not the errorIntercept option | on | serverSettings.interceptError | must be set to off for mID
70
72
  | SERVER_PORT | port of the server | | serverSettings.port |
package/index.js CHANGED
@@ -87,6 +87,8 @@ 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,
91
93
  DEFAULT_BITBUCKET_USERNAME,
92
94
  DEFAULT_BITBUCKET_PASSWORD,
@@ -444,12 +446,15 @@ if (!isMSTSet) {
444
446
  configuration.dependencies = {};
445
447
  }
446
448
  if (process.env.OAUTH_GENERIC_PREVIOUS_KEY) configuration.security.generic.previousKey = process.env.OAUTH_GENERIC_PREVIOUS_KEY;
447
- if (process.env.BITBUCKET_USERNAME) {
449
+ if (process.env.BITBUCKET_USERNAME || process.env.BITBUCKET_PASSWORD) {
448
450
  configuration.serverSettings.apiBasicAuth = {
449
451
  username: process.env.BITBUCKET_USERNAME || DEFAULT_BITBUCKET_USERNAME,
450
452
  password: process.env.BITBUCKET_PASSWORD || DEFAULT_BITBUCKET_PASSWORD,
451
453
  };
452
454
  }
455
+ if (process.env.SWAGGERHUB_API_KEY) {
456
+ configuration.serverSettings.apiApiKey = process.env.SWAGGERHUB_API_KEY;
457
+ }
453
458
  configuration.logInfo = setupLog();
454
459
  configuration.locationProvider = setupLocationProvider();
455
460
 
@@ -472,9 +477,10 @@ configuration.locationProvider = setupLocationProvider();
472
477
  * | SERVER_VERSION | version of the software for the micro-service | package.version | serverSettings.version
473
478
  * | SERVER_NAME | name of the micro-service | package.name | serverSettings.name
474
479
  * | SERVER_TYPE | type of the micro-service | package.mimik.type | serverSettings.type
475
- * | SWAGGER_FILE_VERSION | version of the swagger file for the API | package.swaggerFile.version | serverSettings.swaggerFileVersion
476
- * | SWAGGER_FILE_ACCOUNT | account associated with the API | package.swaggerFile.account |
477
- * | SWAGGER_FILE_NAME | name of the API | package.swaggerFile.name |
480
+ * | SWAGGER_FILE_VERSION | version of the swagger file for the API | package.swaggerFile.version | serverSettings.swaggerFile.version
481
+ * | SWAGGER_FILE_ACCOUNT | account associated with the API | package.swaggerFile.account | serverSettings.swaggerFile.account
482
+ * | SWAGGER_FILE_NAME | name of the API | package.swaggerFile.name | serverSettings.swaggerFile.name
483
+ * | SWAGGER_FILE_PROVIDER | provider of the API file | package.swaggerFile.provider | serverSettings.swaggerFile.provider, if not present the default is `bitbucket`
478
484
  * | SERVER_LOCAL_IPV4 | IP address of the micro-service | ip.address() | serverSettings.ip.local
479
485
  * | CONSOLE_LEVEL | log level for console output | debug | logInfo.consoleLevel
480
486
  * | LOG_LEVEL | log level for console output | debug | logInfo.logLevel
@@ -494,6 +500,7 @@ configuration.locationProvider = setupLocationProvider();
494
500
  * | SWAGGER_FILE_DIRECTORY | directory where the api definition is located | ./api | serverSettings.api | [1]
495
501
  * | BITBUCKET_USERNAME | username to access bitbucket read access on the swagger repos | ' ' | serverSettings.apiBasicAuth.username
496
502
  * | BITBUCKET_PASSWORD | password to access bitbucket read access on the swagger repos | ' ' | serverSettings.apiBasicAuth.password
503
+ * | SWAGGERHUB_API_KEY | apiKey to access swaggerhub | | serverSettings.apiApiKey
497
504
  * | SERVER_SECURITY_SET | switch to enable or disable the token interpretation | on | serverSettings.securitySet | only active if environment is `local`
498
505
  * | INTERCEPT_ERROR | switch to use or not the errorIntercept option | on | serverSettings.interceptError | must be set to off for mID
499
506
  * | SERVER_PORT | port of the server | | serverSettings.port |
@@ -643,6 +650,8 @@ const setConfig = (pack, options) => {
643
650
  process.env.SWAGGER_FILE_VERSION = pack.swaggerFile.version;
644
651
  process.env.SWAGGER_FILE_ACCOUNT = pack.swaggerFile.account;
645
652
  process.env.SWAGGER_FILE_NAME = pack.swaggerFile.name;
653
+ if (pack.swaggerFile.provider) process.env.SWAGGER_FILE_PROVIDER = pack.swaggerFile.provider;
654
+ else process.env.SWAGGER_FILE_PROVIDER = DEFAULT_SWAGGER_FILE_PROVIDER;
646
655
  }
647
656
 
648
657
  // eslint-disable-next-line max-len
@@ -652,7 +661,12 @@ const setConfig = (pack, options) => {
652
661
  configuration.serverSettings.type = process.env.SERVER_TYPE;
653
662
  configuration.serverSettings.version = process.env.SERVER_VERSION;
654
663
  configuration.serverSettings.api = `${process.env.SWAGGER_FILE_DIRECTORY || DEFAULT_SWAGGER_DIR}/${apiFilename}`;
655
- configuration.serverSettings.swaggerFileVersion = process.env.SWAGGER_FILE_VERSION;
664
+ configuration.serverSettings.swaggerFile = {
665
+ version: process.env.SWAGGER_FILE_VERSION,
666
+ name: process.env.SWAGGER_FILE_NAME,
667
+ account: process.env.SWAGGER_FILE_ACCOUNT,
668
+ provider: process.env.SWAGGER_FILE_PROVIDER,
669
+ };
656
670
 
657
671
  // default for every server for cluster management
658
672
  configuration.dependencies[configuration.serverSettings.type] = {
@@ -661,6 +675,9 @@ const setConfig = (pack, options) => {
661
675
 
662
676
  if (isMSTSet) configuration.dependencies[configuration.serverSettings.type].audience = process.env[`${configuration.serverSettings.type}_AUDIENCE`.toUpperCase()];
663
677
 
678
+ if (!SUPPORTED_SWAGGER_FILE_PROVIDERS.includes(configuration.serverSettings.swaggerFile.provider)) {
679
+ throw new Error(`swaggerFile provider not supported: ${configuration.serverSettings.swaggerFile.provider}`);
680
+ }
664
681
  if (options.database) {
665
682
  if (options.database.type === 'mongodb') {
666
683
  configuration.mongoSettings = setupMongo(options.database);
package/lib/common.js CHANGED
@@ -88,6 +88,8 @@ 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, 'swagggerhub'];
91
93
 
92
94
  const DEFAULT_BITBUCKET_USERNAME = ' ';
93
95
  const DEFAULT_BITBUCKET_PASSWORD = ' ';
@@ -165,6 +167,8 @@ module.exports = {
165
167
  DEFAULT_SERVER_PUBLIC_DOMAIN_NAME,
166
168
  DEFAULT_ADMIN_EXTERNAL_ID,
167
169
  DEFAULT_SWAGGER_DIR,
170
+ DEFAULT_SWAGGER_FILE_PROVIDER,
171
+ SUPPORTED_SWAGGER_FILE_PROVIDERS,
168
172
  DEFAULT_INTERCEPT_ERROR,
169
173
  DEFAULT_BITBUCKET_USERNAME,
170
174
  DEFAULT_BITBUCKET_PASSWORD,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mimik/configuration",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "Common configuration for mimik services",
5
5
  "main": "index.js",
6
6
  "scripts": {