serverless-api-gateway-caching
Advanced tools
Comparing version 1.3.8 to 1.4.0
{ | ||
"name": "serverless-api-gateway-caching", | ||
"version": "1.3.8", | ||
"version": "1.4.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", |
@@ -130,1 +130,24 @@ # serverless-api-gateway-caching | ||
``` | ||
### Configuring a shared api gateway | ||
No modifications will be applied to the root caching configuration of the api gateway, | ||
Cache time to live, invalidation settings and data encryption are applied to all functions, unless specifically overridden. | ||
```yml | ||
plugins: | ||
- serverless-api-gateway-caching | ||
custom: | ||
# Enable or disable caching globally | ||
apiGatewayCaching: | ||
enabled: true | ||
apiGatewayIsShared: true | ||
clusterSize: '0.5' # defaults to '0.5' | ||
ttlInSeconds: 300 # defaults to the maximum allowed: 3600 | ||
dataEncrypted: true # defaults to false | ||
perKeyInvalidation: | ||
requireAuthorization: true # default is true | ||
handleUnauthorizedRequests: Ignore # default is "IgnoreWithWarning" | ||
``` |
@@ -81,2 +81,3 @@ const get = require('lodash.get'); | ||
this.cachingEnabled = serverless.service.custom.apiGatewayCaching.enabled; | ||
this.apiGatewayIsShared = serverless.service.custom.apiGatewayCaching.apiGatewayIsShared; | ||
@@ -83,0 +84,0 @@ if (options) { |
@@ -22,2 +22,7 @@ const isEmpty = require('lodash.isempty'); | ||
const createPatchForStage = (settings) => { | ||
if (settings.apiGatewayIsShared) { | ||
return []; | ||
} | ||
let patch = [{ | ||
@@ -27,3 +32,4 @@ op: 'replace', | ||
value: `${settings.cachingEnabled}` | ||
}] | ||
}]; | ||
if (settings.cachingEnabled) { | ||
@@ -35,8 +41,16 @@ patch.push({ | ||
}); | ||
patch.push({ | ||
op: 'replace', | ||
path: '/*/*/caching/dataEncrypted', | ||
value: `${settings.dataEncrypted}` | ||
value: `${settings.dataEncrypted}` | ||
}); | ||
patch.push({ | ||
op: 'replace', | ||
path: '/*/*/caching/ttlInSeconds', | ||
value: `${settings.cacheTtlInSeconds}` | ||
}); | ||
} | ||
return patch; | ||
@@ -43,0 +57,0 @@ } |
24496
442
152