@@ -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
- if ( data . environment )
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 [ environment ] . key ;
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 [ environment ] . webhooks [ webhookName ] ;
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 [ environment ] . eventDataKey
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 [ environment ] . eventNameKey
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 [ environment ] . authenticate && apis [ environment ] . authenticate . method ) {
258
- method = apis [ environment ] . authenticate . method
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 [ environment ] . authenticate && apis [ environment ] . authenticate . parameters ) {
265
- parameters = apis [ environment ] . authenticate . parameters
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
0 commit comments