@cocreate/lazy-loader 1.19.3 → 1.19.4
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 +7 -0
- package/package.json +1 -1
- package/src/server.js +9 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.19.4](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.19.3...v1.19.4) (2024-05-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* removed environment handling variables as it is database specific ([d63921c](https://github.com/CoCreate-app/CoCreate-lazy-loader/commit/d63921cb039c284ab452bf47f0802fc56a66eeb3))
|
|
7
|
+
|
|
1
8
|
## [1.19.3](https://github.com/CoCreate-app/CoCreate-lazy-loader/compare/v1.19.2...v1.19.3) (2024-05-08)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/server.js
CHANGED
|
@@ -156,14 +156,8 @@ class CoCreateLazyLoader {
|
|
|
156
156
|
const name = methodPath.shift()
|
|
157
157
|
|
|
158
158
|
const apis = await this.getApiKey(data, name)
|
|
159
|
-
let environment = 'production';
|
|
160
159
|
|
|
161
|
-
|
|
162
|
-
environment = data.environment
|
|
163
|
-
else if (data.host.startsWith('dev.') || data.host.startsWith('test.'))
|
|
164
|
-
environment = 'test'
|
|
165
|
-
|
|
166
|
-
const key = apis[environment].key;
|
|
160
|
+
const key = apis.key;
|
|
167
161
|
if (!key)
|
|
168
162
|
throw new Error(`Missing ${name} key in organization apis object`);
|
|
169
163
|
|
|
@@ -205,31 +199,25 @@ class CoCreateLazyLoader {
|
|
|
205
199
|
async webhooks(config, data, name) {
|
|
206
200
|
try {
|
|
207
201
|
const apis = await this.getApiKey(data, name)
|
|
208
|
-
let environment = 'production';
|
|
209
|
-
|
|
210
|
-
if (data.environment)
|
|
211
|
-
environment = data.environment
|
|
212
|
-
else if (data.host.startsWith('dev.') || data.host.startsWith('test.'))
|
|
213
|
-
environment = 'test'
|
|
214
202
|
|
|
215
|
-
const key = apis
|
|
203
|
+
const key = apis.key;
|
|
216
204
|
if (!key)
|
|
217
205
|
throw new Error(`Missing ${name} key in organization apis object`);
|
|
218
206
|
|
|
219
207
|
let webhookName = data.req.url.split('/');
|
|
220
208
|
webhookName = webhookName[webhookName.length - 1]
|
|
221
209
|
|
|
222
|
-
const webhook = apis
|
|
210
|
+
const webhook = apis.webhooks[webhookName];
|
|
223
211
|
if (!webhook)
|
|
224
212
|
throw new Error(`Webhook ${name} ${webhookName} is not defined`);
|
|
225
213
|
|
|
226
214
|
// eventDataKey is used to access the event data
|
|
227
|
-
let eventDataKey = webhook.eventDataKey || apis
|
|
215
|
+
let eventDataKey = webhook.eventDataKey || apis.eventDataKey
|
|
228
216
|
if (!eventDataKey)
|
|
229
217
|
throw new Error(`Webhook ${name} eventKey is not defined`);
|
|
230
218
|
|
|
231
219
|
// eventNameKey is used to access the event the event name
|
|
232
|
-
let eventNameKey = webhook.eventNameKey || apis
|
|
220
|
+
let eventNameKey = webhook.eventNameKey || apis.eventNameKey
|
|
233
221
|
if (!eventNameKey)
|
|
234
222
|
throw new Error(`Webhook ${name} eventNameKey is not defined`);
|
|
235
223
|
|
|
@@ -254,15 +242,15 @@ class CoCreateLazyLoader {
|
|
|
254
242
|
|
|
255
243
|
if (webhook.authenticate && webhook.authenticate.method) {
|
|
256
244
|
method = webhook.authenticate.method
|
|
257
|
-
} else if (apis
|
|
258
|
-
method = apis
|
|
245
|
+
} else if (apis.authenticate && apis.authenticate.method) {
|
|
246
|
+
method = apis.authenticate.method
|
|
259
247
|
} else
|
|
260
248
|
throw new Error(`Webhook ${name} authenticate method is not defined`);
|
|
261
249
|
|
|
262
250
|
if (webhook.authenticate && webhook.authenticate.parameters) {
|
|
263
251
|
parameters = webhook.authenticate.parameters
|
|
264
|
-
} else if (apis
|
|
265
|
-
parameters = apis
|
|
252
|
+
} else if (apis.authenticate && apis.authenticate.parameters) {
|
|
253
|
+
parameters = apis.authenticate.parameters
|
|
266
254
|
} else
|
|
267
255
|
throw new Error(`Webhook ${name} authenticate parameters is not defined`);
|
|
268
256
|
|