Skip to content

Commit

Permalink
Merge branch 'release/1.7.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Diana Ionita committed Aug 1, 2021
2 parents 76e19b6 + 4fe8db4 commit c3135b8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-api-gateway-caching",
"version": "1.7.3",
"version": "1.7.4",
"description": "A plugin for the serverless framework which helps with configuring caching for API Gateway endpoints.",
"main": "src/apiGatewayCachingPlugin.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/stageCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const httpEventOf = (lambda, endpointSettings) => {
}
});

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

Expand Down
28 changes: 28 additions & 0 deletions test/updating-stage-cache-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,34 @@ describe('Updating stage cache settings', () => {
});
});

describe('when an http endpoint path is empty', () => {
before(async () => {
let endpoint = given.a_serverless_function('list-cats')
.withHttpEndpoint('get', '', { enabled: true });

serverless = given.a_serverless_instance()
.withApiGatewayCachingConfig()
.withFunction(endpoint)
.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();
apiGatewayRequest = requestsToAws.find(r => r.awsService == apiGatewayService && r.method == updateStageMethod);
});

it(`should enable caching for the endpoint`, () => {
expect(apiGatewayRequest.properties.patchOperations).to.deep.include({
op: 'replace',
path: `/~1/GET/caching/enabled`,
value: 'true'
});
});
});

// https://github.com/DianaIonita/serverless-api-gateway-caching/issues/46
describe('When there are over twenty two http endpoints defined', () => {
let requestsToAwsToUpdateStage, restApiId, expectedStageName;
Expand Down

0 comments on commit c3135b8

Please sign in to comment.