serverless-api-gateway-caching
Advanced tools
Comparing version 1.1.5 to 1.1.6
{ | ||
"name": "serverless-api-gateway-caching", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "A plugin for the serverless framework which helps with configuring caching for API Gateway endpoints.", | ||
@@ -5,0 +5,0 @@ "main": "src/apiGatewayCachingPlugin.js", |
@@ -6,3 +6,3 @@ 'use strict'; | ||
const updateStageCacheSettings = require('./stageCache'); | ||
const { outputRestApiIdTo } = require('./restApiId'); | ||
const { restApiExists, outputRestApiIdTo } = require('./restApiId'); | ||
@@ -26,3 +26,3 @@ class ApiGatewayCachingPlugin { | ||
updateCloudFormationTemplate() { | ||
this.thereIsARestApi = this.restApiExists(); | ||
this.thereIsARestApi = restApiExists(this.serverless); | ||
if (!this.thereIsARestApi) { | ||
@@ -50,12 +50,4 @@ this.serverless.cli.log(`[serverless-api-gateway-caching] No Rest API found. Caching settings will not be updated.`); | ||
} | ||
restApiExists() { | ||
let resource = this.serverless.service.provider.compiledCloudFormationTemplate.Resources['ApiGatewayRestApi']; | ||
if (resource) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
module.exports = ApiGatewayCachingPlugin; |
@@ -6,4 +6,20 @@ 'use strict'; | ||
const getConfiguredRestApiId = (serverless) => { | ||
return get(serverless, 'service.provider.apiGateway.restApiId') | ||
} | ||
const restApiExists = (serverless) => { | ||
const configuredRestApiId = getConfiguredRestApiId(serverless); | ||
if (configuredRestApiId) { | ||
return true; | ||
} | ||
const resource = serverless.service.provider.compiledCloudFormationTemplate.Resources['ApiGatewayRestApi']; | ||
if (resource) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
const outputRestApiIdTo = (serverless) => { | ||
const configuredRestApiId = get(serverless, 'service.provider.apiGateway.restApiId'); | ||
const configuredRestApiId = getConfiguredRestApiId(serverless); | ||
const autoGeneratedRestApiId = { Ref: 'ApiGatewayRestApi' }; | ||
@@ -31,4 +47,5 @@ | ||
module.exports = { | ||
restApiExists, | ||
outputRestApiIdTo, | ||
retrieveRestApiId | ||
}; |
19414
360