Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter by stage for the removing API mapping #620

Merged
merged 5 commits into from Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [7.3.7] - 2023-03-06

### Fixed
- Added filtering by stage for the `getBasePathMappings` method.

## [7.3.6] - 2023-02-13

### Changed
Expand Down
5,092 changes: 4,338 additions & 754 deletions package-lock.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "serverless-domain-manager",
"version": "7.3.6",
"version": "7.3.7",
"engines": {
"node": ">=14"
},
Expand Down Expand Up @@ -50,8 +50,8 @@
},
"devDependencies": {
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.10",
"@types/randomstring": "^1.1.11",
"@types/node": "^20.11.24",
"@types/randomstring": "^1.1.12",
"@types/shelljs": "^0.8.15",
"aws-sdk-client-mock": "^3.0.1",
"chai": "^4.4.1",
Expand All @@ -63,7 +63,7 @@
"eslint-plugin-promise": "^5.2.0",
"@typescript-eslint/parser": "^5.62.0",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"mocha": "^10.2.0",
"mocha": "^10.3.0",
"mocha-param": "^2.0.1",
"nyc": "^15.1.0",
"randomstring": "^1.3.0",
Expand All @@ -74,20 +74,20 @@
"typescript": "^5.1.6 && <5.2"
},
"dependencies": {
"@aws-sdk/client-acm": "^3.460.0",
"@aws-sdk/client-api-gateway": "^3.460.0",
"@aws-sdk/client-apigatewayv2": "^3.460.0",
"@aws-sdk/client-cloudformation": "^3.460.0",
"@aws-sdk/client-route-53": "^3.460.0",
"@aws-sdk/client-s3": "^3.460.0",
"@aws-sdk/credential-providers": "^3.460.0",
"@smithy/config-resolver": "^2.0.19",
"@smithy/node-config-provider": "^2.1.6",
"@smithy/node-http-handler": "^2.1.10",
"@smithy/smithy-client": "^2.1.16",
"@smithy/types": "^2.6.0",
"@smithy/util-retry": "^2.0.7",
"proxy-agent": "^6.3.1"
"@aws-sdk/client-acm": "^3.525.0",
"@aws-sdk/client-api-gateway": "^3.525.0",
"@aws-sdk/client-apigatewayv2": "^3.525.0",
"@aws-sdk/client-cloudformation": "^3.526.0",
"@aws-sdk/client-route-53": "^3.525.0",
"@aws-sdk/client-s3": "^3.525.0",
"@aws-sdk/credential-providers": "^3.525.0",
"@smithy/config-resolver": "^2.1.4",
"@smithy/node-config-provider": "^2.2.4",
"@smithy/node-http-handler": "^2.4.1",
"@smithy/smithy-client": "^2.4.2",
"@smithy/types": "^2.10.1",
"@smithy/util-retry": "^2.1.3",
"proxy-agent": "^6.4.0"
},
"peerDependencies": {
"serverless": "^2.60 || ^3.0.0"
Expand Down
4 changes: 3 additions & 1 deletion src/aws/api-gateway-v1-wrapper.ts
Expand Up @@ -139,7 +139,9 @@ class APIGatewayV1Wrapper extends APIGatewayBase {
domainName: domain.givenDomainName
})
);
return items.map((item) => {
return items.filter((item) => {
return item.stage === domain.stage;
}).map((item) => {
return new ApiGatewayMap(item.restApiId, item.basePath, item.stage, null);
});
} catch (err) {
Expand Down
4 changes: 3 additions & 1 deletion src/aws/api-gateway-v2-wrapper.ts
Expand Up @@ -167,7 +167,9 @@ class APIGatewayV2Wrapper extends APIGatewayBase {
DomainName: domain.givenDomainName
})
);
return items.map(
return items.filter((item) => {
return item.Stage === domain.stage;
}).map(
(item) => new ApiGatewayMap(item.ApiId, item.ApiMappingKey, item.Stage, item.ApiMappingId)
);
} catch (err) {
Expand Down
12 changes: 11 additions & 1 deletion test/unit-tests/aws/api-gateway-v1-wrapper.test.ts
Expand Up @@ -339,6 +339,14 @@ describe("API Gateway V1 wrapper checks", () => {
restApiId: "test_rest_api_id",
basePath: "test",
stage: "test"
}, {
restApiId: "test_rest_api_id2",
basePath: "test2",
stage: "test"
}, {
restApiId: "test_rest_api_id3",
basePath: "test3",
stage: "dummy"
}]
});

Expand All @@ -348,8 +356,10 @@ describe("API Gateway V1 wrapper checks", () => {
}));

const actualResult = await apiGatewayV1Wrapper.getBasePathMappings(dc);
// should be filtered by stage
const expectedResult = [
new ApiGatewayMap("test_rest_api_id", "test", "test", null)
new ApiGatewayMap("test_rest_api_id", "test", "test", null),
new ApiGatewayMap("test_rest_api_id2", "test2", "test", null)
];

expect(actualResult).to.eql(expectedResult);
Expand Down
14 changes: 13 additions & 1 deletion test/unit-tests/aws/api-gateway-v2-wrapper.test.ts
Expand Up @@ -372,6 +372,16 @@ describe("API Gateway V2 wrapper checks", () => {
ApiMappingKey: "test",
Stage: "test",
ApiMappingId: "test_id"
}, {
ApiId: "test_rest_api_id2",
ApiMappingKey: "test2",
Stage: "test",
ApiMappingId: "test_id2"
}, {
ApiId: "test_rest_api_id3",
ApiMappingKey: "test3",
Stage: "dummy",
ApiMappingId: "test_id3"
}]
});

Expand All @@ -381,8 +391,10 @@ describe("API Gateway V2 wrapper checks", () => {
}));

const actualResult = await apiGatewayV2Wrapper.getBasePathMappings(dc);
// should be filtered by stage
const expectedResult = [
new ApiGatewayMap("test_rest_api_id", "test", "test", "test_id")
new ApiGatewayMap("test_rest_api_id", "test", "test", "test_id"),
new ApiGatewayMap("test_rest_api_id2", "test2", "test", "test_id2")
];

expect(actualResult).to.eql(expectedResult);
Expand Down