Skip to content

Commit c3135b8

Browse files
author
Diana Ionita
committed
Merge branch 'release/1.7.4'
2 parents 76e19b6 + 4fe8db4 commit c3135b8

4 files changed

+31
-3
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-api-gateway-caching",
3-
"version": "1.7.3",
3+
"version": "1.7.4",
44
"description": "A plugin for the serverless framework which helps with configuring caching for API Gateway endpoints.",
55
"main": "src/apiGatewayCachingPlugin.js",
66
"scripts": {

src/stageCache.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const httpEventOf = (lambda, endpointSettings) => {
106106
}
107107
});
108108

109-
return httpEvents.filter(e => e.path = endpointSettings.path || "/" + e.path === endpointSettings.path)
109+
return httpEvents.filter(e => (e.path === endpointSettings.path) || (`/${e.path}` === endpointSettings.path))
110110
.filter(e => e.method.toUpperCase() == endpointSettings.method.toUpperCase());
111111
}
112112

test/updating-stage-cache-settings.js

+28
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,34 @@ describe('Updating stage cache settings', () => {
667667
});
668668
});
669669

670+
describe('when an http endpoint path is empty', () => {
671+
before(async () => {
672+
let endpoint = given.a_serverless_function('list-cats')
673+
.withHttpEndpoint('get', '', { enabled: true });
674+
675+
serverless = given.a_serverless_instance()
676+
.withApiGatewayCachingConfig()
677+
.withFunction(endpoint)
678+
.forStage('somestage');
679+
settings = new ApiGatewayCachingSettings(serverless);
680+
681+
restApiId = await given.a_rest_api_id_for_deployment(serverless, settings);
682+
683+
await when_updating_stage_cache_settings(settings, serverless);
684+
685+
requestsToAws = serverless.getRequestsToAws();
686+
apiGatewayRequest = requestsToAws.find(r => r.awsService == apiGatewayService && r.method == updateStageMethod);
687+
});
688+
689+
it(`should enable caching for the endpoint`, () => {
690+
expect(apiGatewayRequest.properties.patchOperations).to.deep.include({
691+
op: 'replace',
692+
path: `/~1/GET/caching/enabled`,
693+
value: 'true'
694+
});
695+
});
696+
});
697+
670698
// https://github.com/DianaIonita/serverless-api-gateway-caching/issues/46
671699
describe('When there are over twenty two http endpoints defined', () => {
672700
let requestsToAwsToUpdateStage, restApiId, expectedStageName;

0 commit comments

Comments
 (0)