Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d63921c

Browse files
fix: removed environment handling variables as it is database specific
1 parent 41f190e commit d63921c

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

‎src/server.js‎

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,8 @@ class CoCreateLazyLoader {
156156
const name = methodPath.shift()
157157

158158
const apis = await this.getApiKey(data, name)
159-
let environment = 'production';
160159

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;
167161
if (!key)
168162
throw new Error(`Missing ${name} key in organization apis object`);
169163

@@ -205,31 +199,25 @@ class CoCreateLazyLoader {
205199
async webhooks(config, data, name) {
206200
try {
207201
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'
214202

215-
const key = apis[environment].key;
203+
const key = apis.key;
216204
if (!key)
217205
throw new Error(`Missing ${name} key in organization apis object`);
218206

219207
let webhookName = data.req.url.split('/');
220208
webhookName = webhookName[webhookName.length - 1]
221209

222-
const webhook = apis[environment].webhooks[webhookName];
210+
const webhook = apis.webhooks[webhookName];
223211
if (!webhook)
224212
throw new Error(`Webhook ${name} ${webhookName} is not defined`);
225213

226214
// eventDataKey is used to access the event data
227-
let eventDataKey = webhook.eventDataKey || apis[environment].eventDataKey
215+
let eventDataKey = webhook.eventDataKey || apis.eventDataKey
228216
if (!eventDataKey)
229217
throw new Error(`Webhook ${name} eventKey is not defined`);
230218

231219
// 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
233221
if (!eventNameKey)
234222
throw new Error(`Webhook ${name} eventNameKey is not defined`);
235223

@@ -254,15 +242,15 @@ class CoCreateLazyLoader {
254242

255243
if (webhook.authenticate && webhook.authenticate.method) {
256244
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
259247
} else
260248
throw new Error(`Webhook ${name} authenticate method is not defined`);
261249

262250
if (webhook.authenticate && webhook.authenticate.parameters) {
263251
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
266254
} else
267255
throw new Error(`Webhook ${name} authenticate parameters is not defined`);
268256

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /