serverless-api-gateway-throttling
Advanced tools
Comparing version 2.0.1-rc1 to 2.0.1-rc2
{ | ||
"name": "serverless-api-gateway-throttling", | ||
"version": "2.0.1-rc1", | ||
"version": "2.0.1-rc2", | ||
"description": "A plugin for the Serverless framework which configures throttling for API Gateway endpoints.", | ||
@@ -5,0 +5,0 @@ "main": "src/apiGatewayThrottlingPlugin.js", |
@@ -16,11 +16,8 @@ 'use strict'; | ||
if (serverless.service.provider.compiledCloudFormationTemplate) { | ||
const resource = serverless.service.provider.compiledCloudFormationTemplate.Resources['HttpApi']; | ||
if (resource) { | ||
return true; | ||
} | ||
if (httpApiExistsInCloudFormationTemplate(serverless)) { | ||
return true; | ||
} | ||
if (settings) { | ||
const httpApiIdFromAlreadyDeployedStack = await retrieveHttpApiId(serverless, settings); | ||
const httpApiIdFromAlreadyDeployedStack = await retrieveHttpApiIdFromAlreadyDeployedStack(serverless, settings); | ||
if (httpApiIdFromAlreadyDeployedStack) { | ||
@@ -33,2 +30,14 @@ return true; | ||
const retrieveHttpApiId = async (serverless, settings) => { | ||
const configuredHttpApiId = getConfiguredHttpApiId(serverless); | ||
if (configuredHttpApiId) { | ||
return configuredHttpApiId; | ||
} | ||
const HttpApiId = await retrieveHttpApiIdFromAlreadyDeployedStack(serverless, settings); | ||
if (!HttpApiId) { | ||
serverless.cli.log(`[serverless-api-gateway-throttling] Could not find stack output variable named ${HTTP_API_ID_KEY}.`); | ||
} | ||
}; | ||
const outputHttpApiIdTo = (serverless) => { | ||
@@ -44,2 +53,21 @@ const configuredHttpApiId = getConfiguredHttpApiId(serverless); | ||
const httpApiExistsInCloudFormationTemplate = (serverless) => { | ||
if (serverless.service.provider.compiledCloudFormationTemplate) { | ||
const resource = serverless.service.provider.compiledCloudFormationTemplate.Resources['HttpApi']; | ||
if (resource) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
const retrieveHttpApiIdFromAlreadyDeployedStack = async (serverless, settings) => { | ||
const stack = await getAlreadyDeployedStack(serverless, settings); | ||
const outputs = stack.Stacks[0].Outputs; | ||
const HttpApiKey = outputs.find(({ OutputKey }) => OutputKey === HTTP_API_ID_KEY) | ||
if (HttpApiKey) { | ||
return HttpApiKey.OutputValue; | ||
} | ||
} | ||
const getAlreadyDeployedStack = async (serverless, settings) => { | ||
@@ -60,19 +88,2 @@ const stackName = serverless.providers.aws.naming.getStackName(settings.stage); | ||
const retrieveHttpApiId = async (serverless, settings) => { | ||
const configuredHttpApiId = getConfiguredHttpApiId(serverless); | ||
if (configuredHttpApiId) { | ||
return configuredHttpApiId; | ||
} | ||
const stack = await getAlreadyDeployedStack(serverless, settings); | ||
const outputs = stack.Stacks[0].Outputs; | ||
const restApiKey = outputs.find(({ OutputKey }) => OutputKey === HTTP_API_ID_KEY) | ||
if (restApiKey) { | ||
return restApiKey.OutputValue; | ||
} | ||
else { | ||
serverless.cli.log(`[serverless-api-gateway-throttling] Could not find stack output variable named ${HTTP_API_ID_KEY}.`); | ||
} | ||
}; | ||
module.exports = { | ||
@@ -79,0 +90,0 @@ httpApiExists, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30783
634