mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
remove duplicated methods
_createEndpointMethodResponses
_createEndpointMethodIntegResponses
This commit is contained in:
parent
c87d3db002
commit
a2dfbf4e7a
@ -794,116 +794,6 @@ ApiDeployer.prototype._createEndpointMethodIntegResponses = Promise.method(funct
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* API Deployer: Create Endpoint Method Responses
|
||||
*/
|
||||
|
||||
ApiDeployer.prototype._createEndpointMethodResponses = Promise.method(function(endpoint) {
|
||||
|
||||
var _this = this;
|
||||
|
||||
return Promise.try(function() {
|
||||
|
||||
// Collect Response Keys
|
||||
if (endpoint.apiGateway.cloudFormation.Responses) return Object.keys(endpoint.apiGateway.cloudFormation.Responses);
|
||||
else return [];
|
||||
})
|
||||
.each(function(responseKey) {
|
||||
|
||||
var thisResponse = endpoint.apiGateway.cloudFormation.Responses[responseKey];
|
||||
var methodResponseBody = {};
|
||||
|
||||
// Format Response Parameters per APIG API's Expectations
|
||||
for (prop in thisResponse.responseParameters) {
|
||||
var param = endpoint.apiGateway.cloudFormation.ResponseParameters[prop];
|
||||
methodResponseBody.responseParameters[param[prop]] = true;
|
||||
}
|
||||
|
||||
// Create Method Response
|
||||
return _this.ApiClient.putMethodResponse(
|
||||
_this._restApiId,
|
||||
endpoint.apiGateway.apig.resource.id,
|
||||
endpoint.apiGateway.cloudFormation.Method,
|
||||
thisResponse.statusCode,
|
||||
methodResponseBody)
|
||||
.then(function() {
|
||||
JawsCli.log(
|
||||
'Endpoint Deployer: "'
|
||||
+ _this._stage
|
||||
+ ' - '
|
||||
+ _this._regionJson.region
|
||||
+ ' - '
|
||||
+ endpoint.apiGateway.cloudFormation.Path
|
||||
+ '": '
|
||||
+ 'created method response');
|
||||
})
|
||||
.catch(function(error) {
|
||||
throw new JawsError(
|
||||
error.message,
|
||||
JawsError.errorCodes.UNKNOWN);
|
||||
});
|
||||
})
|
||||
.then(function() {
|
||||
return endpoint;
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* API Deployer: Create Endpoint Method Integration Responses
|
||||
*/
|
||||
|
||||
ApiDeployer.prototype._createEndpointMethodIntegResponses = Promise.method(function(endpoint) {
|
||||
|
||||
var _this = this;
|
||||
|
||||
return Promise.try(function() {
|
||||
|
||||
// Collect Response Keys
|
||||
if (endpoint.apiGateway.cloudFormation.Responses) {
|
||||
return Object.keys(endpoint.apiGateway.cloudFormation.Responses);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
})
|
||||
.each(function(responseKey) {
|
||||
|
||||
var thisResponse = endpoint.apiGateway.cloudFormation.Responses[responseKey];
|
||||
var integrationResponseBody = {};
|
||||
|
||||
// Add Response Parameters
|
||||
integrationResponseBody.responseParameters = thisResponse.responseParameters;
|
||||
|
||||
// Add Response Templates
|
||||
integrationResponseBody.responseTemplates = thisResponse.responseTemplates;
|
||||
|
||||
// Add SelectionPattern
|
||||
integrationResponseBody.selectionPattern = responseKey === 'default' ? null : responseKey;// null = default
|
||||
|
||||
// Create Integration Response
|
||||
return _this.ApiClient.putIntegrationResponse(
|
||||
_this._restApiId,
|
||||
endpoint.apiGateway.apig.resource.id,
|
||||
endpoint.apiGateway.cloudFormation.Method,
|
||||
thisResponse.statusCode,
|
||||
integrationResponseBody)
|
||||
.then(function() {
|
||||
JawsCli.log(
|
||||
'Endpoint Deployer: "'
|
||||
+ _this._stage
|
||||
+ ' - '
|
||||
+ _this._regionJson.region
|
||||
+ ' - '
|
||||
+ endpoint.apiGateway.cloudFormation.Path
|
||||
+ '": '
|
||||
+ 'created method integration response');
|
||||
}).catch(function(error) {
|
||||
throw new JawsError(
|
||||
error.message,
|
||||
JawsError.errorCodes.UNKNOWN);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* API Deployer: Create Deployment
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user