serverless-api-gateway-caching
Advanced tools
Comparing version 1.8.1 to 1.9.0-rc1
@@ -0,0 +0,0 @@ { |
{ | ||
"name": "serverless-api-gateway-caching", | ||
"version": "1.8.1", | ||
"version": "1.9.0-rc1", | ||
"description": "A plugin for the serverless framework which helps with configuring caching for API Gateway endpoints.", | ||
@@ -5,0 +5,0 @@ "main": "src/apiGatewayCachingPlugin.js", |
@@ -0,0 +0,0 @@ # serverless-api-gateway-caching |
@@ -144,2 +144,22 @@ 'use strict'; | ||
dataEncrypted: { type: 'boolean' }, | ||
perKeyInvalidation: { | ||
type: 'object', | ||
properties: { | ||
requireAuthorization: { type: 'boolean' }, | ||
handleUnauthorizedRequests: { | ||
type: 'string', | ||
enum: ['Ignore', 'IgnoreWithWarning', 'Fail'] | ||
} | ||
} | ||
}, | ||
cacheKeyParameters: { | ||
type: 'array', | ||
items: { | ||
type: 'object', | ||
properties: { | ||
name: { type: 'string' }, | ||
value: { type: 'string' } | ||
} | ||
} | ||
} | ||
} | ||
@@ -146,0 +166,0 @@ } |
@@ -91,2 +91,3 @@ const get = require('lodash.get'); | ||
} | ||
this.pathWithoutGlobalBasePath = this.path; | ||
this.path = basePath.concat(this.path); | ||
@@ -117,7 +118,20 @@ } | ||
this.path = path; | ||
this.cachingEnabled = globalSettings.cachingEnabled ? get(caching, 'enabled', false) : false; | ||
if (caching) { | ||
this.cacheTtlInSeconds = caching.ttlInSeconds >= 0 ? caching.ttlInSeconds : globalSettings.cacheTtlInSeconds; | ||
this.gatewayResourceName = getApiGatewayResourceNameFor(this.path, this.method); | ||
if (!caching) { | ||
this.cachingEnabled = false; | ||
return; | ||
} | ||
this.dataEncrypted = get(caching, 'dataEncrypted', globalSettings.dataEncrypted); | ||
const cachingConfig = caching; | ||
this.cachingEnabled = globalSettings.cachingEnabled ? cachingConfig.enabled : false; | ||
this.dataEncrypted = cachingConfig.dataEncrypted || globalSettings.dataEncrypted; | ||
this.cacheTtlInSeconds = caching.ttlInSeconds >= 0 ? caching.ttlInSeconds : globalSettings.cacheTtlInSeconds; | ||
this.cacheKeyParameters = cachingConfig.cacheKeyParameters; | ||
if (!cachingConfig.perKeyInvalidation) { | ||
this.perKeyInvalidation = globalSettings.perKeyInvalidation; | ||
} else { | ||
this.perKeyInvalidation = new PerKeyInvalidationSettings(cachingConfig); | ||
} | ||
} | ||
@@ -152,9 +166,2 @@ } | ||
const additionalEndpoints = cachingSettings.additionalEndpoints || []; | ||
for (let additionalEndpoint of additionalEndpoints) { | ||
const { method, path, caching } = additionalEndpoint; | ||
this.additionalEndpointSettings.push(new ApiGatewayAdditionalEndpointCachingSettings(method, path, caching, this)) | ||
} | ||
this.perKeyInvalidation = new PerKeyInvalidationSettings(cachingSettings); | ||
@@ -170,2 +177,8 @@ | ||
} | ||
const additionalEndpoints = cachingSettings.additionalEndpoints || []; | ||
for (let additionalEndpoint of additionalEndpoints) { | ||
const { method, path, caching } = additionalEndpoint; | ||
this.additionalEndpointSettings.push(new ApiGatewayAdditionalEndpointCachingSettings(method, path, caching, this)) | ||
} | ||
} | ||
@@ -172,0 +185,0 @@ } |
@@ -10,4 +10,4 @@ const getResourcesByName = (name, serverless) => { | ||
const addPathParametersCacheConfig = (settings, serverless) => { | ||
for (let endpointSettings of settings.endpointSettings) { | ||
const applyPathParameterCacheSettings = (settings, serverless) => { | ||
for (let endpointSettings of settings) { | ||
if (!endpointSettings.cacheKeyParameters) { | ||
@@ -19,3 +19,3 @@ continue; | ||
serverless.cli.log(`[serverless-api-gateway-caching] The method ${endpointSettings.gatewayResourceName} couldn't be found in the | ||
compiled CloudFormation template. Caching settings will not be updated for this endpoint.`); | ||
compiled CloudFormation template. Caching settings will not be updated for this endpoint.`); | ||
continue; | ||
@@ -63,2 +63,6 @@ } | ||
} | ||
const addPathParametersCacheConfig = (settings, serverless) => { | ||
applyPathParameterCacheSettings(settings.endpointSettings, serverless); | ||
applyPathParameterCacheSettings(settings.additionalEndpointSettings, serverless); | ||
} | ||
@@ -65,0 +69,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -109,4 +109,7 @@ const isEmpty = require('lodash.isempty'); | ||
return httpEvents.filter(e => (e.path === endpointSettings.path) || (`/${e.path}` === endpointSettings.path)) | ||
.filter(e => e.method.toUpperCase() == endpointSettings.method.toUpperCase()); | ||
return httpEvents.filter(e => | ||
(e.path === endpointSettings.path) || | ||
(`/${e.path}` === endpointSettings.path) || | ||
(e.path == endpointSettings.pathWithoutGlobalBasePath) || | ||
(`/${e.path}` == endpointSettings.pathWithoutGlobalBasePath)); | ||
} | ||
@@ -172,3 +175,3 @@ | ||
} | ||
for (let index in paramsInChunks) { | ||
@@ -175,0 +178,0 @@ serverless.cli.log(`[serverless-api-gateway-caching] Updating API Gateway cache settings (${parseInt(index) + 1} of ${paramsInChunks.length}).`); |
@@ -0,0 +0,0 @@ module.exports = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
44401
660
2