Skip to content

Commit ba0c573

Browse files
authored
fix(apigw): fix describe api missing issue (#68)
* fix(apigw): fix describe api missing issue * feat(apigw): update service type dependence
1 parent 4e2e860 commit ba0c573

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/modules/apigw/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ class Apigw {
108108
};
109109
}
110110

111-
marshalApiInput(endpoint, apiInputs, serviceType) {
111+
marshalApiInput(endpoint, apiInputs) {
112112
if (endpoint.param) {
113113
apiInputs.requestParameters = endpoint.param;
114114
}
115115

116-
apiInputs.serviceType = serviceType;
116+
const { serviceType } = apiInputs;
117117
endpoint.function = endpoint.function || {};
118118
// handle front-end API type of WEBSOCKET/HTTP
119119
if (endpoint.protocol === 'WEBSOCKET') {
@@ -241,7 +241,10 @@ class Apigw {
241241
}
242242
}
243243
}
244-
} else {
244+
}
245+
246+
// get API info after apiId confirmed
247+
if (endpoint.apiId) {
245248
apiDetail = await this.request({
246249
Action: 'DescribeApi',
247250
serviceId: serviceId,
@@ -254,7 +257,7 @@ class Apigw {
254257
}
255258

256259
if (!exist) {
257-
this.marshalApiInput(endpoint, apiInputs, apiInputs.serviceType);
260+
this.marshalApiInput(endpoint, apiInputs);
258261
const { ApiId } = await this.request({
259262
Action: 'CreateApi',
260263
...apiInputs,
@@ -272,7 +275,7 @@ class Apigw {
272275
output.internalDomain = apiDetail.InternalDomain;
273276
} else {
274277
console.log(`Updating api with api id ${endpoint.apiId}.`);
275-
this.marshalApiInput(endpoint, apiInputs, apiDetail.ServiceType);
278+
this.marshalApiInput(endpoint, apiInputs);
276279
await this.request({
277280
Action: 'ModifyApi',
278281
apiId: endpoint.apiId,

src/modules/apigw/index.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@ async function runTest() {
8282
method: 'GET',
8383
},
8484
},
85+
{
86+
path: '/wsf',
87+
protocol: 'WEBSOCKET',
88+
apiName: 'ws-scf',
89+
method: 'GET',
90+
serviceType: 'SCF',
91+
function: {
92+
functionNamespace: 'default',
93+
functionQualifier: '$DEFAULT',
94+
transportFunctionName: 'fullstack-api',
95+
registerFunctionName: 'myRestAPI',
96+
},
97+
},
8598
],
8699
};
87100
const apigw = new Apigw(credentials, inputs.region);

0 commit comments

Comments
 (0)