@cocreate/lazy-loader 1.19.0 → 1.19.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.19.1](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.19.0...v1.19.1) (2024-04-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * eniroment declaration and error handling of execute method ([659d947](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/659d947af1226c77b4cbcbaaed10596ade73183f))
7
+
1
8
  # [1.19.0](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.18.0...v1.19.0) (2024-04-26)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/lazy-loader",
3
- "version": "1.19.0",
3
+ "version": "1.19.1",
4
4
  "description": "A simple lazy-loader component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "lazy-loader",
package/src/server.js CHANGED
@@ -156,7 +156,13 @@ class CoCreateLazyLoader {
156
156
  const name = methodPath.shift()
157
157
 
158
158
  const apis = await this.getApiKey(data, name)
159
- const environment = data.environment || 'production';
159
+ let environment = 'production';
160
+
161
+ if (data.environment)
162
+ environment = data.environment
163
+ else if (data.host.startsWith('dev.') || data.host.startsWith('test.'))
164
+ environment = 'test'
165
+
160
166
  const key = apis[environment].key;
161
167
  if (!key)
162
168
  throw new Error(`Missing ${name} key in organization apis object`);
@@ -199,8 +205,9 @@ class CoCreateLazyLoader {
199
205
  async webhooks(config, data, name) {
200
206
  try {
201
207
  const apis = await this.getApiKey(data, name)
202
- let environment = data.environment || 'production';
203
- if (data.host.startsWith('dev.') || data.host.startsWith('test.'))
208
+ if (data.environment)
209
+ environment = data.environment
210
+ else if (data.host.startsWith('dev.') || data.host.startsWith('test.'))
204
211
  environment = 'test'
205
212
 
206
213
  const key = apis[environment].key;
@@ -443,7 +450,7 @@ async function executeMethod(method, methodPath, instance, params) {
443
450
  return await Method[methodName](...params)
444
451
  }
445
452
  } catch (error) {
446
- throw new Error(`Method ${method} not found.`);
453
+ throw new Error(error);
447
454
  }
448
455
  }
449
456