serverless-api-gateway-caching
Advanced tools
Comparing version 1.2.2 to 1.3.0
{ | ||
"name": "serverless-api-gateway-caching", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"description": "A plugin for the serverless framework which helps with configuring caching for API Gateway endpoints.", | ||
@@ -5,0 +5,0 @@ "main": "src/apiGatewayCachingPlugin.js", |
@@ -68,3 +68,3 @@ # serverless-api-gateway-caching | ||
### Configuring the cache cluster size and cache time to live | ||
Cache time to live and invalidation settings are applied to all functions, unless specifically overridden. | ||
Cache time to live, invalidation settings and data encryption are applied to all functions, unless specifically overridden. | ||
@@ -81,2 +81,3 @@ ```yml | ||
ttlInSeconds: 300 # defaults to the maximum allowed: 3600 | ||
dataEncrypted: true # defaults to false | ||
perKeyInvalidation: | ||
@@ -88,3 +89,3 @@ requireAuthorization: true # default is true | ||
### Configuring per-function cache time to live, cache invalidation strategy and cache key parameters | ||
### Configuring per-function cache time to live, cache invalidation strategy, cache key parameters and cache data encryption | ||
@@ -111,2 +112,3 @@ ```yml | ||
ttlInSeconds: 3600 | ||
dataEncrypted: true # default is false | ||
perKeyInvalidation: | ||
@@ -113,0 +115,0 @@ requireAuthorization: true # default is true |
@@ -1,2 +0,1 @@ | ||
const isEmpty = require('lodash.isempty'); | ||
const get = require('lodash.get'); | ||
@@ -6,2 +5,3 @@ const { Ignore, IgnoreWithWarning, Fail } = require('./UnauthorizedCacheControlHeaderStrategy'); | ||
const DEFAULT_CACHE_CLUSTER_SIZE = '0.5'; | ||
const DEFAULT_DATA_ENCRYPTED = false; | ||
const DEFAULT_TTL = 3600; | ||
@@ -57,5 +57,6 @@ const DEFAULT_UNAUTHORIZED_INVALIDATION_REQUEST_STRATEGY = IgnoreWithWarning; | ||
this.cachingEnabled = globalSettings.cachingEnabled ? cachingConfig.enabled : false; | ||
this.dataEncrypted = cachingConfig.dataEncrypted || globalSettings.dataEncrypted; | ||
this.cacheTtlInSeconds = cachingConfig.ttlInSeconds || globalSettings.cacheTtlInSeconds; | ||
this.cacheKeyParameters = cachingConfig.cacheKeyParameters; | ||
if (!cachingConfig.perKeyInvalidation) { | ||
@@ -88,2 +89,3 @@ this.perKeyInvalidation = globalSettings.perKeyInvalidation; | ||
this.cacheTtlInSeconds = serverless.service.custom.apiGatewayCaching.ttlInSeconds || DEFAULT_TTL; | ||
this.dataEncrypted = serverless.service.custom.apiGatewayCaching.dataEncrypted || DEFAULT_DATA_ENCRYPTED; | ||
@@ -90,0 +92,0 @@ this.perKeyInvalidation = new PerKeyInvalidationSettings(serverless.service.custom.apiGatewayCaching); |
@@ -20,2 +20,3 @@ const split = require('lodash.split'); | ||
element = element.replaceAll('_', ''); | ||
element = element.replaceAll('.', ''); | ||
if (element.startsWith('{')) { | ||
@@ -22,0 +23,0 @@ element = element.substring(element.indexOf('{') + 1, element.indexOf('}')) + "Var"; |
@@ -48,3 +48,8 @@ const isEmpty = require('lodash.isempty'); | ||
value: `${endpointSettings.cacheTtlInSeconds}` | ||
}) | ||
}); | ||
patch.push({ | ||
op: 'replace', | ||
path: `/${patchPath}/caching/dataEncrypted`, | ||
value: `${endpointSettings.dataEncrypted}` | ||
}); | ||
} | ||
@@ -70,4 +75,4 @@ if (endpointSettings.perKeyInvalidation) { | ||
return lambda.events.filter(e => e.http != undefined) | ||
.filter(e => e.http.path === endpointSettings.path || "/" + e.http.path === endpointSettings.path) | ||
.filter(e => e.http.method === endpointSettings.method); | ||
.filter(e => e.http.path === endpointSettings.path || "/" + e.http.path === endpointSettings.path) | ||
.filter(e => e.http.method.toUpperCase() === endpointSettings.method.toUpperCase()); | ||
} | ||
@@ -81,3 +86,3 @@ | ||
} | ||
const httpEvents = httpEventOf(lambda,endpointSettings); | ||
const httpEvents = httpEventOf(lambda, endpointSettings); | ||
if (isEmpty(httpEvents)) { | ||
@@ -84,0 +89,0 @@ serverless.cli.log(`[serverless-api-gateway-caching] Lambda ${endpointSettings.functionName} has not defined any HTTP events.`); |
21434
379
117