From f073daf12ed39a52ebd5f15fffbd0e231bd1d54f Mon Sep 17 00:00:00 2001 From: Diana Ionita Date: Sat, 14 Nov 2020 15:52:59 +0000 Subject: [PATCH 1/4] Adding support for caching for functions defined in CloudFormation --- src/ApiGatewayCachingSettings.js | 35 ++++-- src/stageCache.js | 14 ++- test/creating-settings.js | 51 ++++++++ test/model/Serverless.js | 20 ++-- test/steps/given.js | 11 +- ...cache-settings-for-additional-endpoints.js | 109 ++++++++++++++++++ test/updating-stage-cache-settings.js | 6 +- 7 files changed, 222 insertions(+), 24 deletions(-) create mode 100644 test/updating-stage-cache-settings-for-additional-endpoints.js diff --git a/src/ApiGatewayCachingSettings.js b/src/ApiGatewayCachingSettings.js index d5e5c94..ee4d3ef 100644 --- a/src/ApiGatewayCachingSettings.js +++ b/src/ApiGatewayCachingSettings.js @@ -40,8 +40,7 @@ class PerKeyInvalidationSettings { } class ApiGatewayEndpointCachingSettings { - constructor(customFunctionName, functionName, event, globalSettings) { - this.customFunctionName = customFunctionName; + constructor(functionName, event, globalSettings) { this.functionName = functionName; if (typeof (event.http) === 'string') { @@ -76,13 +75,23 @@ class ApiGatewayEndpointCachingSettings { } } +class ApiGatewayAdditionalEndpointCachingSettings { + constructor(method, path, caching, globalSettings) { + this.method = method; + this.path = path; + this.cachingEnabled = globalSettings.cachingEnabled ? caching.enabled : false; + this.cacheTtlInSeconds = caching.ttlInSeconds || globalSettings.cacheTtlInSeconds; + } +} + class ApiGatewayCachingSettings { constructor(serverless, options) { if (!get(serverless, 'service.custom.apiGatewayCaching')) { return; } - this.cachingEnabled = serverless.service.custom.apiGatewayCaching.enabled; - this.apiGatewayIsShared = serverless.service.custom.apiGatewayCaching.apiGatewayIsShared; + const cachingSettings = serverless.service.custom.apiGatewayCaching; + this.cachingEnabled = cachingSettings.enabled; + this.apiGatewayIsShared = cachingSettings.apiGatewayIsShared; if (options) { this.stage = options.stage || serverless.service.provider.stage; @@ -93,18 +102,26 @@ class ApiGatewayCachingSettings { } this.endpointSettings = []; + this.additionalEndpointSettings = []; - this.cacheClusterSize = serverless.service.custom.apiGatewayCaching.clusterSize || DEFAULT_CACHE_CLUSTER_SIZE; - this.cacheTtlInSeconds = serverless.service.custom.apiGatewayCaching.ttlInSeconds || DEFAULT_TTL; - this.dataEncrypted = serverless.service.custom.apiGatewayCaching.dataEncrypted || DEFAULT_DATA_ENCRYPTED; + this.cacheClusterSize = cachingSettings.clusterSize || DEFAULT_CACHE_CLUSTER_SIZE; + this.cacheTtlInSeconds = cachingSettings.ttlInSeconds || DEFAULT_TTL; + this.dataEncrypted = cachingSettings.dataEncrypted || DEFAULT_DATA_ENCRYPTED; + + 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(serverless.service.custom.apiGatewayCaching); + this.perKeyInvalidation = new PerKeyInvalidationSettings(cachingSettings); for (let functionName in serverless.service.functions) { let functionSettings = serverless.service.functions[functionName]; for (let event in functionSettings.events) { if (isApiGatewayEndpoint(functionSettings.events[event])) { - this.endpointSettings.push(new ApiGatewayEndpointCachingSettings(functionSettings.name, functionName, functionSettings.events[event], this)) + this.endpointSettings.push(new ApiGatewayEndpointCachingSettings(functionName, functionSettings.events[event], this)) } } } diff --git a/src/stageCache.js b/src/stageCache.js index 8a9c5f8..2c87b46 100644 --- a/src/stageCache.js +++ b/src/stageCache.js @@ -40,7 +40,7 @@ const createPatchForStage = (settings) => { patch.push({ op: 'replace', path: '/*/*/caching/dataEncrypted', - value: `${settings.dataEncrypted}` + value: `${settings.dataEncrypted}` }); patch.push({ @@ -49,7 +49,7 @@ const createPatchForStage = (settings) => { value: `${settings.cacheTtlInSeconds}` }); } - + return patch; } @@ -183,7 +183,8 @@ const updateStageCacheSettings = async (settings, serverless) => { let patchOps = createPatchForStage(settings); - let endpointsWithCachingEnabled = settings.endpointSettings.filter(e => e.cachingEnabled); + let endpointsWithCachingEnabled = settings.endpointSettings.filter(e => e.cachingEnabled) + .concat(settings.additionalEndpointSettings.filter(e => e.cachingEnabled)); if (settings.cachingEnabled && isEmpty(endpointsWithCachingEnabled)) { serverless.cli.log(`[serverless-api-gateway-caching] [WARNING] API Gateway caching is enabled but none of the endpoints have caching enabled`); } @@ -192,6 +193,13 @@ const updateStageCacheSettings = async (settings, serverless) => { let endpointPatch = createPatchForEndpoint(endpointSettings, serverless); patchOps = patchOps.concat(endpointPatch); } + + // TODO handle 'ANY' method, if possible + for (let additionalEndpointSettings of settings.additionalEndpointSettings) { + let endpointPatch = patchForMethod(additionalEndpointSettings.path, additionalEndpointSettings.method, additionalEndpointSettings); + patchOps = patchOps.concat(endpointPatch); + } + let params = { restApiId, stageName: settings.stage, diff --git a/test/creating-settings.js b/test/creating-settings.js index 861385a..070cf56 100644 --- a/test/creating-settings.js +++ b/test/creating-settings.js @@ -454,6 +454,57 @@ describe('Creating settings', () => { }); }); + describe('when there are additional endpoints defined', () => { + describe('and caching is turned off globally', () => { + before(() => { + serverless = given.a_serverless_instance() + .withApiGatewayCachingConfig(false) + .withAdditionalEndpoints([{ method: 'GET', path: '/shelter', caching: { enabled: true } }]); + + cacheSettings = createSettingsFor(serverless); + }); + + it('caching should be disabled for the additional endpoints', () => { + expect(cacheSettings.additionalEndpointSettings[0].cachingEnabled).to.be.false; + }); + }); + + describe('and caching is turned on globally', () => { + before(() => { + serverless = given.a_serverless_instance() + .withApiGatewayCachingConfig(true, '1', 20); + }); + + describe('and only the fact that caching is enabled is specified on the additional endpoint', () => { + before(() => { + let caching = { enabled: true } + serverless = serverless + .withAdditionalEndpoints([{ method: 'GET', path: '/shelter', caching }]); + + cacheSettings = createSettingsFor(serverless); + }); + + it('should inherit time to live settings from global settings', () => { + expect(cacheSettings.additionalEndpointSettings[0].cacheTtlInSeconds).to.equal(20); + }); + }); + + describe('and the time to live is specified', () => { + before(() => { + let caching = { enabled: true, ttlInSeconds: 67 } + serverless = serverless + .withAdditionalEndpoints([{ method: 'GET', path: '/shelter', caching }]); + + cacheSettings = createSettingsFor(serverless); + }); + + it('should set the correct time to live', () => { + expect(cacheSettings.additionalEndpointSettings[0].cacheTtlInSeconds).to.equal(67); + }); + }); + }); + }); + describe('when there are command line options for the deployment', () => { let options; before(() => { diff --git a/test/model/Serverless.js b/test/model/Serverless.js index 3608be2..6b026a1 100644 --- a/test/model/Serverless.js +++ b/test/model/Serverless.js @@ -65,6 +65,11 @@ class Serverless { return this; } + withAdditionalEndpoints(additionalEndpoints){ + this.service.custom.apiGatewayCaching.additionalEndpoints = additionalEndpoints; + return this; + } + withPredefinedRestApiId(restApiId) { if (!this.service.provider.apiGateway) { this.service.provider.apiGateway = {} @@ -95,20 +100,19 @@ class Serverless { }, request: async (awsService, method, properties, stage, region) => { this._recordedAwsRequests.push({ awsService, method, properties, stage, region }); + if (awsService == 'CloudFormation' && method == 'describeStacks' && properties.StackName == 'serverless-stack-name' && stage == settings.stage && region == settings.region) { return { - Stacks: [ - { - Outputs: [{ - OutputKey: 'RestApiIdForApigCaching', - OutputValue: restApiId - }] - } - ] + Stacks: [{ + Outputs: [{ + OutputKey: 'RestApiIdForApigCaching', + OutputValue: restApiId + }] + }] }; } } diff --git a/test/steps/given.js b/test/steps/given.js index 1c7b0cf..5c4cbb7 100644 --- a/test/steps/given.js +++ b/test/steps/given.js @@ -32,10 +32,19 @@ const endpoints_with_caching_enabled = (endpointCount) => { return result; } +const an_additional_endpoint = ({ method, path, caching }) => { + return { + method, + path, + caching + } +} + module.exports = { a_serverless_instance, a_serverless_function, a_rest_api_id, a_rest_api_id_for_deployment, - endpoints_with_caching_enabled + endpoints_with_caching_enabled, + an_additional_endpoint } diff --git a/test/updating-stage-cache-settings-for-additional-endpoints.js b/test/updating-stage-cache-settings-for-additional-endpoints.js new file mode 100644 index 0000000..e083eb1 --- /dev/null +++ b/test/updating-stage-cache-settings-for-additional-endpoints.js @@ -0,0 +1,109 @@ +const APP_ROOT = '..'; +const given = require(`${APP_ROOT}/test/steps/given`); +const ApiGatewayCachingSettings = require(`${APP_ROOT}/src/ApiGatewayCachingSettings`); +const updateStageCacheSettings = require(`${APP_ROOT}/src/stageCache`); +const UnauthorizedCacheControlHeaderStrategy = require(`${APP_ROOT}/src/UnauthorizedCacheControlHeaderStrategy`); +const expect = require('chai').expect; + +describe('Updating stage cache settings for additional endpoints defined as CloudFormation', () => { + let serverless, settings, requestsToAws, apiGatewayRequest; + const apiGatewayService = 'APIGateway', updateStageMethod = 'updateStage'; + + // TODO + describe('When API Gateway caching is disabled', () => { + describe('and there are only additional endpoints defined', () => { + // disables caching + }); + }); + + describe('When API Gateway caching is enabled', () => { + describe('and there are additionalEndpoints configured for HTTP endpoints defined as CloudFormation', () => { + describe('and there are no other endpoints with caching enabled', () => { + }); + + describe('and there are other endpoints with caching enabled', () => { + + }); + }); + }); + + + // Described in https://github.com/DianaIonita/serverless-api-gateway-caching/pull/68 + describe('When there are additionalEndpoints configured for HTTP endpoints defined as CloudFormation', () => { + const additionalEndpoints = [given.an_additional_endpoint({ method: 'GET', path: '/', caching: { enabled: true, ttlInSeconds: 120 } })]; + + describe('and there are no other endpoints with caching enabled', () => { + before(async () => { + serverless = given.a_serverless_instance() + .withApiGatewayCachingConfig(true, '0.5', 60) + .withAdditionalEndpoints(additionalEndpoints) + .forStage('somestage'); + settings = new ApiGatewayCachingSettings(serverless); + + restApiId = await given.a_rest_api_id_for_deployment(serverless, settings); + + await when_updating_stage_cache_settings(settings, serverless); + + requestsToAws = serverless.getRequestsToAws(); + }); + + describe('the request sent to AWS SDK to update stage', () => { + before(() => { + apiGatewayRequest = requestsToAws.find(r => r.awsService == apiGatewayService && r.method == updateStageMethod); + }); + + it('should contain the Rest Api Id', () => { + expect(apiGatewayRequest.properties.restApiId).to.equal(restApiId); + }); + + it('should contain the stage name', () => { + expect(apiGatewayRequest.properties.stageName).to.equal('somestage'); + }); + + it('should specify exactly four patch operations', () => { + expect(apiGatewayRequest.properties.patchOperations).to.have.lengthOf(4); + }) + + it('should enable caching', () => { + expect(apiGatewayRequest.properties.patchOperations).to.deep.include({ + op: 'replace', + path: '/cacheClusterEnabled', + value: 'true' + }); + }); + + it('should set the cache cluster size', () => { + expect(apiGatewayRequest.properties.patchOperations).to.deep.include({ + op: 'replace', + path: '/cacheClusterSize', + value: '0.5' + }); + }); + + it('should set the cache encryption', () => { + expect(apiGatewayRequest.properties.patchOperations).to.deep.include({ + op: 'replace', + path: '/*/*/caching/dataEncrypted', + value: 'false' + }); + }); + + it('should set the cache ttlInSeconds', () => { + expect(apiGatewayRequest.properties.patchOperations).to.deep.include({ + op: 'replace', + path: '/*/*/caching/ttlInSeconds', + value: '60' + }); + }); + }); + }); + + describe('and there are other endpoints with caching enabled', () => { + + }) + }); +}); + +const when_updating_stage_cache_settings = async (settings, serverless) => { + return await updateStageCacheSettings(settings, serverless); +} diff --git a/test/updating-stage-cache-settings.js b/test/updating-stage-cache-settings.js index fb65c50..d6aa5cf 100644 --- a/test/updating-stage-cache-settings.js +++ b/test/updating-stage-cache-settings.js @@ -140,10 +140,10 @@ describe('Updating stage cache settings', () => { expect(apiGatewayRequest.properties.stageName).to.equal('somestage'); }); - it('should leave caching untouched', noOperationAreExpectedForPath ('/cacheClusterEnabled')); + it('should leave caching untouched', noOperationAreExpectedForPath('/cacheClusterEnabled')); + + it('should leave the cache cluster size untouched', noOperationAreExpectedForPath('/cacheClusterSize')); - it('should leave the cache cluster size untouched', noOperationAreExpectedForPath ('/cacheClusterSize')); - describe('for the endpoint with caching enabled', () => { it('should enable caching', () => { expect(apiGatewayRequest.properties.patchOperations).to.deep.include({ From 1c34a5b7862ffe5a2291d9c47fbe252516dab73a Mon Sep 17 00:00:00 2001 From: Diana Ionita Date: Sun, 29 Nov 2020 17:42:16 +0000 Subject: [PATCH 2/4] Added tests around additionalEndpoints --- README.md | 56 ++++++++++++ package.json | 2 +- src/ApiGatewayCachingSettings.js | 5 +- test/creating-settings.js | 41 ++++++++- ...cache-settings-for-additional-endpoints.js | 86 ++++++++++++------- test/updating-stage-cache-settings.js | 2 +- 6 files changed, 154 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 209fd3b..b747d54 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,62 @@ custom: handleUnauthorizedRequests: Ignore ``` +## Configuring caching settings for endpoints defined in CloudFormation +You can use this feature to configure caching for endpoints which are defined in CloudFormation and not as serverless functions. +If your `serverless.yml` contains, for example, a [HTTP Proxy](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/#setting-an-http-proxy-on-api-gateway) like this: + +```yml +resources: + Resources: + ProxyResource: + Type: AWS::ApiGateway::Resource + Properties: + ParentId: + Fn::GetAtt: + - ApiGatewayRestApi # the default Rest API logical ID + - RootResourceId + PathPart: serverless # the endpoint in your API that is set as proxy + RestApiId: + Ref: ApiGatewayRestApi + ProxyMethod: + Type: AWS::ApiGateway::Method + Properties: + ResourceId: + Ref: ProxyResource + RestApiId: + Ref: ApiGatewayRestApi + HttpMethod: GET + AuthorizationType: NONE + MethodResponses: + - StatusCode: 200 + Integration: + IntegrationHttpMethod: POST + Type: HTTP + Uri: http://serverless.com # the URL you want to set a proxy to + IntegrationResponses: + - StatusCode: 200 +``` + +Then you can configure caching for it like this: + +```yml +plugins: + - serverless-api-gateway-caching + +custom: + apiGatewayCaching: + enabled: true + additionalEndpoints: + - method: GET + path: /serverless + caching: + enabled: true # it must be specifically enabled + ttlInSeconds: 1200 # if not set, inherited from global settings + dataEncrypted: true # if not set, inherited from global settings +``` + + + ## More Examples A function with several endpoints: diff --git a/package.json b/package.json index de9bf2c..0d2dce8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serverless-api-gateway-caching", - "version": "1.5.1", + "version": "1.6.0-rc1", "description": "A plugin for the serverless framework which helps with configuring caching for API Gateway endpoints.", "main": "src/apiGatewayCachingPlugin.js", "scripts": { diff --git a/src/ApiGatewayCachingSettings.js b/src/ApiGatewayCachingSettings.js index ee4d3ef..f0621ae 100644 --- a/src/ApiGatewayCachingSettings.js +++ b/src/ApiGatewayCachingSettings.js @@ -79,8 +79,9 @@ class ApiGatewayAdditionalEndpointCachingSettings { constructor(method, path, caching, globalSettings) { this.method = method; this.path = path; - this.cachingEnabled = globalSettings.cachingEnabled ? caching.enabled : false; - this.cacheTtlInSeconds = caching.ttlInSeconds || globalSettings.cacheTtlInSeconds; + this.cachingEnabled = globalSettings.cachingEnabled ? get(caching, 'enabled', false) : false; + this.cacheTtlInSeconds = get(caching, 'ttlInSeconds', globalSettings.cacheTtlInSeconds); + this.dataEncrypted = get(caching, 'dataEncrypted', globalSettings.dataEncrypted); } } diff --git a/test/creating-settings.js b/test/creating-settings.js index 070cf56..63bbe0b 100644 --- a/test/creating-settings.js +++ b/test/creating-settings.js @@ -475,9 +475,22 @@ describe('Creating settings', () => { .withApiGatewayCachingConfig(true, '1', 20); }); + describe('and no caching settings are defined for the additional endpoint', () => { + before(() => { + serverless = serverless + .withAdditionalEndpoints([{ method: 'GET', path: '/shelter' }]); + + cacheSettings = createSettingsFor(serverless); + }); + + it('should disable caching for the endpoint', () => { + expect(cacheSettings.additionalEndpointSettings[0].cachingEnabled).to.equal(false); + }); + }); + describe('and only the fact that caching is enabled is specified on the additional endpoint', () => { before(() => { - let caching = { enabled: true } + let caching = { enabled: true }; serverless = serverless .withAdditionalEndpoints([{ method: 'GET', path: '/shelter', caching }]); @@ -487,6 +500,10 @@ describe('Creating settings', () => { it('should inherit time to live settings from global settings', () => { expect(cacheSettings.additionalEndpointSettings[0].cacheTtlInSeconds).to.equal(20); }); + + it('should inherit data encryption settings from global settings', () => { + expect(cacheSettings.additionalEndpointSettings[0].dataEncrypted).to.equal(false); + }); }); describe('and the time to live is specified', () => { @@ -501,6 +518,28 @@ describe('Creating settings', () => { it('should set the correct time to live', () => { expect(cacheSettings.additionalEndpointSettings[0].cacheTtlInSeconds).to.equal(67); }); + + it('should inherit data encryption settings from global settings', () => { + expect(cacheSettings.additionalEndpointSettings[0].dataEncrypted).to.equal(false); + }); + }); + + describe('and data encryption is specified', () => { + before(() => { + let caching = { enabled: true, dataEncrypted: true } + serverless = serverless + .withAdditionalEndpoints([{ method: 'GET', path: '/shelter', caching }]); + + cacheSettings = createSettingsFor(serverless); + }); + + it('should set the correct data encryption', () => { + expect(cacheSettings.additionalEndpointSettings[0].dataEncrypted).to.equal(true); + }); + + it('should inherit time to live settings from global settings', () => { + expect(cacheSettings.additionalEndpointSettings[0].cacheTtlInSeconds).to.equal(20); + }); }); }); }); diff --git a/test/updating-stage-cache-settings-for-additional-endpoints.js b/test/updating-stage-cache-settings-for-additional-endpoints.js index e083eb1..5e56363 100644 --- a/test/updating-stage-cache-settings-for-additional-endpoints.js +++ b/test/updating-stage-cache-settings-for-additional-endpoints.js @@ -1,39 +1,27 @@ -const APP_ROOT = '..'; -const given = require(`${APP_ROOT}/test/steps/given`); -const ApiGatewayCachingSettings = require(`${APP_ROOT}/src/ApiGatewayCachingSettings`); -const updateStageCacheSettings = require(`${APP_ROOT}/src/stageCache`); -const UnauthorizedCacheControlHeaderStrategy = require(`${APP_ROOT}/src/UnauthorizedCacheControlHeaderStrategy`); +const given = require('../test/steps/given'); +const ApiGatewayCachingSettings = require('../src/ApiGatewayCachingSettings'); +const updateStageCacheSettings = require('../src/stageCache'); const expect = require('chai').expect; describe('Updating stage cache settings for additional endpoints defined as CloudFormation', () => { let serverless, settings, requestsToAws, apiGatewayRequest; const apiGatewayService = 'APIGateway', updateStageMethod = 'updateStage'; - // TODO - describe('When API Gateway caching is disabled', () => { - describe('and there are only additional endpoints defined', () => { - // disables caching - }); - }); - - describe('When API Gateway caching is enabled', () => { - describe('and there are additionalEndpoints configured for HTTP endpoints defined as CloudFormation', () => { - describe('and there are no other endpoints with caching enabled', () => { - }); - - describe('and there are other endpoints with caching enabled', () => { - - }); - }); - }); - - // Described in https://github.com/DianaIonita/serverless-api-gateway-caching/pull/68 - describe('When there are additionalEndpoints configured for HTTP endpoints defined as CloudFormation', () => { - const additionalEndpoints = [given.an_additional_endpoint({ method: 'GET', path: '/', caching: { enabled: true, ttlInSeconds: 120 } })]; + describe('When API Gateway caching is enabled', () => { - describe('and there are no other endpoints with caching enabled', () => { + describe('and there are additionalEndpoints configured for HTTP endpoints defined as CloudFormation', () => { before(async () => { + const additionalEndpoints = [ + given.an_additional_endpoint({ + method: 'GET', path: '/items', + caching: { enabled: true, ttlInSeconds: 120 } + }), + given.an_additional_endpoint({ + method: 'POST', path: '/blue-items', + caching: { enabled: false } + })]; + serverless = given.a_serverless_instance() .withApiGatewayCachingConfig(true, '0.5', 60) .withAdditionalEndpoints(additionalEndpoints) @@ -60,9 +48,9 @@ describe('Updating stage cache settings for additional endpoints defined as Clou expect(apiGatewayRequest.properties.stageName).to.equal('somestage'); }); - it('should specify exactly four patch operations', () => { - expect(apiGatewayRequest.properties.patchOperations).to.have.lengthOf(4); - }) + it('should specify exactly eight patch operations', () => { + expect(apiGatewayRequest.properties.patchOperations).to.have.lengthOf(8); + }); it('should enable caching', () => { expect(apiGatewayRequest.properties.patchOperations).to.deep.include({ @@ -96,11 +84,43 @@ describe('Updating stage cache settings for additional endpoints defined as Clou }); }); }); - }); - describe('and there are other endpoints with caching enabled', () => { + describe('for the endpoint with caching enabled', () => { + it('should enable caching', () => { + expect(apiGatewayRequest.properties.patchOperations).to.deep.include({ + op: 'replace', + path: '/~1items/GET/caching/enabled', + value: 'true' + }); + }); - }) + it('should set the correct cache time to live', () => { + expect(apiGatewayRequest.properties.patchOperations).to.deep.include({ + op: 'replace', + path: '/~1items/GET/caching/ttlInSeconds', + value: '120' + }); + }); + + it('should specify whether data is encrypted', () => { + expect(apiGatewayRequest.properties.patchOperations).to.deep.include({ + op: 'replace', + path: '/~1items/GET/caching/dataEncrypted', + value: 'false' + }); + }); + }); + + describe('for each endpoint with caching disabled', () => { + it('should disable caching', () => { + expect(apiGatewayRequest.properties.patchOperations).to.deep.include({ + op: 'replace', + path: '/~1blue-items/POST/caching/enabled', + value: 'false' + }); + }); + }); + }); }); }); diff --git a/test/updating-stage-cache-settings.js b/test/updating-stage-cache-settings.js index d6aa5cf..6939151 100644 --- a/test/updating-stage-cache-settings.js +++ b/test/updating-stage-cache-settings.js @@ -77,7 +77,7 @@ describe('Updating stage cache settings', () => { }); }); - describe('When api gateway caching is true but api gateway is shared', () => { + describe('When api gateway caching is enabled and the api gateway is shared', () => { let restApiId; describe('and there are no endpoints for which to enable caching', () => { From 67d48a29240edbe054e1b64efaf0064627b9d850 Mon Sep 17 00:00:00 2001 From: Diana Ionita Date: Sun, 29 Nov 2020 17:48:23 +0000 Subject: [PATCH 3/4] Removed extra lines in readme --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index b747d54..ddd26c4 100644 --- a/README.md +++ b/README.md @@ -336,8 +336,6 @@ custom: dataEncrypted: true # if not set, inherited from global settings ``` - - ## More Examples A function with several endpoints: From 903b9ce7258a7ffefed6746186e0c752d5b5bd36 Mon Sep 17 00:00:00 2001 From: Diana Ionita Date: Sun, 29 Nov 2020 17:54:31 +0000 Subject: [PATCH 4/4] version++ --- README.md | 3 ++- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ddd26c4..60efa8c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # serverless-api-gateway-caching -![npm](https://img.shields.io/npm/v/serverless-api-gateway-caching.svg) [![CircleCI](https://circleci.com/gh/DianaIonita/serverless-api-gateway-caching.svg?style=svg)](https://circleci.com/gh/DianaIonita/serverless-api-gateway-caching) +![npm](https://img.shields.io/npm/v/serverless-api-gateway-caching.svg) +[![npm downloads](https://img.shields.io/npm/dt/serverless-api-gateway-caching.svg?style=svg)](https://www.npmjs.com/package/serverless-api-gateway-caching) ## Intro A plugin for the serverless framework which helps with configuring caching for API Gateway endpoints. diff --git a/package-lock.json b/package-lock.json index b92e761..5bdf2d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "serverless-api-gateway-caching", - "version": "1.5.2-rc1", + "version": "1.6.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7ff7434..118e404 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serverless-api-gateway-caching", - "version": "1.5.2", + "version": "1.6.0", "description": "A plugin for the serverless framework which helps with configuring caching for API Gateway endpoints.", "main": "src/apiGatewayCachingPlugin.js", "scripts": {