@onlineapps/content-resolver 1.1.5 → 1.1.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +23 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlineapps/content-resolver",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Automatic conversion between text content and storage references with Content Descriptor pattern",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -109,16 +109,33 @@ class ContentResolver {
109
109
  this.threshold = options.threshold || DEFAULT_THRESHOLD;
110
110
  this.logger = options.logger || console;
111
111
 
112
- // Storage can be passed as instance or config
112
+ // Storage can be passed as instance or config (no fallbacks - fail-fast)
113
113
  if (options.storage instanceof StorageConnector) {
114
114
  this.storage = options.storage;
115
+ } else if (options.storage) {
116
+ // Config passed explicitly
117
+ this.storageConfig = options.storage;
118
+ this.storage = null;
115
119
  } else {
116
- this.storageConfig = options.storage || {
117
- endPoint: process.env.MINIO_HOST || 'api_shared_storage',
118
- port: parseInt(process.env.MINIO_PORT || '9000'),
120
+ // Must have env variables if no config passed
121
+ if (!process.env.MINIO_HOST) {
122
+ throw new Error('[ContentResolver] Missing required: MINIO_HOST env or options.storage');
123
+ }
124
+ if (!process.env.MINIO_PORT) {
125
+ throw new Error('[ContentResolver] Missing required: MINIO_PORT env or options.storage');
126
+ }
127
+ if (!process.env.MINIO_ACCESS_KEY) {
128
+ throw new Error('[ContentResolver] Missing required: MINIO_ACCESS_KEY env or options.storage');
129
+ }
130
+ if (!process.env.MINIO_SECRET_KEY) {
131
+ throw new Error('[ContentResolver] Missing required: MINIO_SECRET_KEY env or options.storage');
132
+ }
133
+ this.storageConfig = {
134
+ endPoint: process.env.MINIO_HOST,
135
+ port: parseInt(process.env.MINIO_PORT),
119
136
  useSSL: false,
120
- accessKey: process.env.MINIO_ACCESS_KEY || 'minioadmin',
121
- secretKey: process.env.MINIO_SECRET_KEY || 'minioadmin',
137
+ accessKey: process.env.MINIO_ACCESS_KEY,
138
+ secretKey: process.env.MINIO_SECRET_KEY,
122
139
  defaultBucket: 'workflow'
123
140
  };
124
141
  this.storage = null;