Skip to content

Commit e0a6b44

Browse files
author
dfounderliu
committed
fix: code format
1 parent ad78979 commit e0a6b44

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/baas/apigw/index.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const {apigw} = require('tencent-cloud-sdk')
2-
const {uniqueArray} = require('../../utils/index')
1+
const { apigw } = require('tencent-cloud-sdk')
2+
const { uniqueArray } = require('../../utils/index')
33

44
class Apigw {
55
constructor(credentials = {}, region) {
@@ -55,8 +55,7 @@ class Apigw {
5555
protocol: protocols
5656
})
5757
}
58-
} catch (e) {
59-
}
58+
} catch (e) {}
6059
}
6160
if (!exist) {
6261
const createData = await this.request({
@@ -77,7 +76,7 @@ class Apigw {
7776
}
7877
}
7978

80-
async createOrUpdateApi({serviceId, endpoint}) {
79+
async createOrUpdateApi({ serviceId, endpoint }) {
8180
const output = {
8281
path: endpoint.path,
8382
method: endpoint.method,
@@ -107,8 +106,8 @@ class Apigw {
107106
const funcQualifier = endpoint.function.functionQualifier
108107
? endpoint.function.functionQualifier
109108
: '$LATEST'
110-
? endpoint.function.functionQualifier
111-
: '$LATEST'
109+
? endpoint.function.functionQualifier
110+
: '$LATEST'
112111

113112
if (endpoint.protocol === 'WEBSOCKET') {
114113
if (!endpoint.function.transportFunctionName) {
@@ -152,7 +151,10 @@ class Apigw {
152151
})
153152
if (pathAPIList.apiIdStatusSet) {
154153
for (let i = 0; i < pathAPIList.apiIdStatusSet.length; i++) {
155-
if (pathAPIList.apiIdStatusSet[i].method == endpoint.method && pathAPIList.apiIdStatusSet[i].path == endpoint.path) {
154+
if (
155+
pathAPIList.apiIdStatusSet[i].method == endpoint.method &&
156+
pathAPIList.apiIdStatusSet[i].path == endpoint.path
157+
) {
156158
endpoint.apiId = pathAPIList.apiIdStatusSet[i].apiId
157159
}
158160
}
@@ -177,13 +179,11 @@ class Apigw {
177179
output.apiId = endpoint.apiId
178180
console.log(`Service with id ${output.apiId} updated.`)
179181
}
180-
} catch (e) {
181-
}
182+
} catch (e) {}
182183
}
183184

184-
185185
if (!exist) {
186-
const {apiId} = await this.request({
186+
const { apiId } = await this.request({
187187
Action: 'CreateApi',
188188
...apiInputs
189189
})
@@ -192,7 +192,7 @@ class Apigw {
192192
console.log(`API with id ${output.apiId} created.`)
193193
}
194194

195-
const {internalDomain} = await this.request({
195+
const { internalDomain } = await this.request({
196196
Action: 'DescribeApi',
197197
serviceId: serviceId,
198198
apiId: output.apiId
@@ -202,15 +202,15 @@ class Apigw {
202202
return output
203203
}
204204

205-
async setupUsagePlanSecret({secretName, secretIds}) {
205+
async setupUsagePlanSecret({ secretName, secretIds }) {
206206
const secretIdsOutput = {
207207
created: false,
208208
secretIds
209209
}
210210

211211
if (secretIds.length === 0) {
212212
console.log(`Creating a new Secret key.`)
213-
const {secretId, secretKey} = await this.request({
213+
const { secretId, secretKey } = await this.request({
214214
Action: 'CreateApiKey',
215215
secretName: secretName,
216216
type: 'auto'
@@ -222,7 +222,7 @@ class Apigw {
222222
const uniqSecretIds = uniqueArray(secretIds)
223223

224224
// get all secretId, check local secretId exists
225-
const {apiKeyStatusSet} = await this.request({
225+
const { apiKeyStatusSet } = await this.request({
226226
Action: 'DescribeApiKeysStatus',
227227
secretIds: uniqSecretIds,
228228
limit: uniqSecretIds.length
@@ -259,7 +259,7 @@ class Apigw {
259259
return secretIdsOutput
260260
}
261261

262-
async setupApiUsagePlan({usagePlan}) {
262+
async setupApiUsagePlan({ usagePlan }) {
263263
const usageInputs = {
264264
usagePlanName: usagePlan.usagePlanName || '',
265265
usagePlanDesc: usagePlan.usagePlanDesc || '',
@@ -295,9 +295,9 @@ class Apigw {
295295
/**
296296
* get all unbound secretids
297297
*/
298-
async getUnboundSecretIds({usagePlanId, secretIds}) {
299-
const getAllBoundSecrets = async (res = [], {limit, offset = 0}) => {
300-
const {secretIdList} = await this.request({
298+
async getUnboundSecretIds({ usagePlanId, secretIds }) {
299+
const getAllBoundSecrets = async (res = [], { limit, offset = 0 }) => {
300+
const { secretIdList } = await this.request({
301301
Action: 'DescribeUsagePlanSecretIds',
302302
usagePlanId,
303303
limit,
@@ -306,9 +306,9 @@ class Apigw {
306306
if (secretIdList.length < limit) {
307307
return res
308308
}
309-
return getAllBoundSecrets(res, {limit, offset: offset + secretIdList.length})
309+
return getAllBoundSecrets(res, { limit, offset: offset + secretIdList.length })
310310
}
311-
const allBoundSecretObjs = await getAllBoundSecrets([], {limit: 100})
311+
const allBoundSecretObjs = await getAllBoundSecrets([], { limit: 100 })
312312
const allBoundSecretIds = allBoundSecretObjs.map((item) => item.secretId)
313313
const unboundSecretIds = secretIds.filter((item) => {
314314
if (allBoundSecretIds.indexOf(item) === -1) {
@@ -321,8 +321,8 @@ class Apigw {
321321
}
322322

323323
// bind custom domains
324-
async bindCustomDomain({serviceId, subDomain, inputs}) {
325-
const {customDomains, oldState = {}} = inputs
324+
async bindCustomDomain({ serviceId, subDomain, inputs }) {
325+
const { customDomains, oldState = {} } = inputs
326326
// 1. unbind all custom domain
327327
const customDomainDetail = await this.request({
328328
Action: 'DescribeServiceSubDomains',
@@ -333,7 +333,7 @@ class Apigw {
333333
customDomainDetail.domainSet &&
334334
customDomainDetail.domainSet.length > 0
335335
) {
336-
const {domainSet = []} = customDomainDetail
336+
const { domainSet = [] } = customDomainDetail
337337
// unbind all created domain
338338
const stateDomains = oldState.customDomains || []
339339
for (let i = 0; i < domainSet.length; i++) {
@@ -389,14 +389,14 @@ class Apigw {
389389

390390
// bind environment fo usage plan
391391
async bindUsagePlanEnvironment({
392-
environment,
393-
bindType = 'API',
394-
serviceId,
395-
apiId,
396-
endpoint,
397-
usagePlan
398-
}) {
399-
const {usagePlanList} = await this.request({
392+
environment,
393+
bindType = 'API',
394+
serviceId,
395+
apiId,
396+
endpoint,
397+
usagePlan
398+
}) {
399+
const { usagePlanList } = await this.request({
400400
Action: 'DescribeApiUsagePlan',
401401
serviceId,
402402
apiIds: [apiId]
@@ -424,17 +424,17 @@ class Apigw {
424424
}
425425

426426
async deploy(inputs) {
427-
const {environment, oldState = {}} = inputs
427+
const { environment, oldState = {} } = inputs
428428
inputs.protocols = this.getProtocolString(inputs.protocols)
429429

430-
const {serviceId, serviceName, subDomain, serviceCreated} = await this.createOrUpdateService(
430+
const { serviceId, serviceName, subDomain, serviceCreated } = await this.createOrUpdateService(
431431
inputs
432432
)
433433

434434
const apiList = []
435435
const stateApiList = oldState.apiList || []
436436

437-
const {endpoints} = inputs
437+
const { endpoints } = inputs
438438
for (let i = 0, len = endpoints.length; i < len; i++) {
439439
const endpoint = endpoints[i]
440440
// if exist in state list, set created to be true
@@ -466,7 +466,7 @@ class Apigw {
466466
// store in api list
467467
curApi.usagePlan = usagePlan
468468

469-
const {secretIds = []} = endpoint.auth
469+
const { secretIds = [] } = endpoint.auth
470470
const secrets = await this.setupUsagePlanSecret({
471471
secretName: endpoint.auth.secretName,
472472
secretIds
@@ -538,15 +538,15 @@ class Apigw {
538538
}
539539

540540
async remove(inputs) {
541-
const {created, environment, serviceId, apiList, customDomains} = inputs
541+
const { created, environment, serviceId, apiList, customDomains } = inputs
542542
// 1. remove all apis
543543
for (let i = 0; i < apiList.length; i++) {
544544
const curApi = apiList[i]
545545

546546
// 1. remove usage plan
547547
if (curApi.usagePlan) {
548548
// 1.1 unbind secrete ids
549-
const {secrets} = curApi.usagePlan
549+
const { secrets } = curApi.usagePlan
550550
if (secrets && secrets.secretIds) {
551551
await this.request({
552552
Action: 'UnBindSecretIds',

0 commit comments

Comments
 (0)