Skip to content

Commit e3f8e88

Browse files
authored
Remove JS SDK v2 examples (#222)
1 parent 9976dea commit e3f8e88

File tree

13 files changed

+48
-451
lines changed

13 files changed

+48
-451
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
---
22
name: Bug report
33
about: Create a report to help us improve
4-
title: ''
5-
labels: ''
6-
assignees: ''
7-
4+
title: ""
5+
labels: ""
6+
assignees: ""
87
---
98

109
<!--
1110
This template is for cutting bugs with aws-sdk-js-tests package.
12-
Use the following links for creating bugs with AWS JS SDK v2/v3:
13-
* v2 https://github.com/aws/aws-sdk-js/issues/new/choose
14-
* v3 https://github.com/aws/aws-sdk-js-v3/issues/new/choose
11+
Use the following link for creating bugs with AWS SDK for JavaScript:
12+
* https://github.com/aws/aws-sdk-js-v3/issues/new/choose
1513
-->
1614

1715
## Describe the bug
16+
1817
A clear and concise description of what the bug is.
1918

2019
## Steps to reproduce
20+
2121
Steps to reproduce the behavior.
2222

2323
#### Observed behavior
24+
2425
A clear and concise description of what happens.
2526

2627
#### Expected behavior
28+
2729
A clear and concise description of what you were expecting to happen.
2830

2931
#### Screenshots
32+
3033
If applicable, add screenshots to help explain your problem.
3134

3235
## Additional context
36+
3337
Add any other context about the problem here.
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
title: ''
5-
labels: ''
6-
assignees: ''
7-
4+
title: ""
5+
labels: ""
6+
assignees: ""
87
---
98

109
<!--
1110
This template is for creating feature requests with aws-sdk-js-tests package.
12-
Use the following links for creating feature requests with AWS JS SDK v2/v3:
13-
* v2 https://github.com/aws/aws-sdk-js/issues/new/choose
14-
* v3 https://github.com/aws/aws-sdk-js-v3/issues/new/choose
11+
Use the following link for creating feature request with AWS SDK for JavaScript:
12+
* https://github.com/aws/aws-sdk-js-v3/issues/new/choose
1513
-->
1614

1715
### Is your feature request related to a problem? Please describe.
16+
1817
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
1918

2019
### Describe the solution you'd like
20+
2121
A clear and concise description of what you want to happen.
2222

2323
### Describe alternatives you've considered
24+
2425
A clear and concise description of any alternative solutions or features you've considered.
2526

2627
### Additional context
28+
2729
Add any other context or screenshots about the feature request here.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Code Samples for testing AWS SDK for JavaScript.
1515
- Run `corepack enable` to let corepack manage version of yarn.
1616
- Update REGION in [`packages/utils/src/config.js`](./packages/utils/src/config.js).
1717
- For browser and react-native, IDENTITY_POOL_ID also needs to be updated.
18-
- [Create a Amazon Cognito Identity pool for testing](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-started-browser.html#getting-started-browser-create-identity-pool)
18+
- [Create a Amazon Cognito Identity pool for testing](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/getting-started-browser.html#getting-started-browser-create-identity-pool)
1919
- Note down IDENTITY_POOL_ID
20-
- [Add a Policy to the test Unauthenticated IAM Role](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-started-browser.html#getting-started-browser-iam-role)
20+
- [Add a Policy to the test Unauthenticated IAM Role](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/getting-started-browser.html#getting-started-browser-iam-role)
2121
- The policy should be specific to the operations you want to test
2222
- Update the IDENTITY_POOL_ID in [`packages/utils/src/config.js`](./packages/utils/src/config.js).
2323

@@ -28,7 +28,7 @@ Code Samples for testing AWS SDK for JavaScript.
2828

2929
### Node.js:
3030

31-
- Run `yarn start:node` to run both v2 and v3 clients in Node.js
31+
- Run `yarn start:node` to run SDK clients in Node.js
3232
- The responses returned by clients will be printed in console, and will re-run when code is updated.
3333
- The file being run is at [`packages/node/src/index.js`](./packages/node/src/index.js).
3434

img/screenshot-android.png

92.2 KB
Loading

img/screenshot-ios.png

-24.2 KB
Loading

img/screenshot-node.png

429 KB
Loading

img/screenshot-web.png

203 KB
Loading

packages/node/src/index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import { REGION, getV2Response, getV3Response } from "@aws-sdk/test-utils";
1+
import { REGION, getResponse } from "@aws-sdk/test-utils";
22

33
(async () => {
44
let response;
55

6-
response = await getV2Response({ region: REGION });
7-
console.log("Data returned by v2:");
8-
console.log(JSON.stringify(response, null, 2));
9-
10-
response = await getV3Response({ region: REGION });
11-
console.log("\nData returned by v3:");
6+
response = await getResponse({ region: REGION });
7+
console.log("\nData returned:");
128
console.log(JSON.stringify(response, null, 2));
139
})();

packages/react-native/App.js

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,31 @@ import 'react-native-get-random-values';
1717
import 'react-native-url-polyfill/auto';
1818
import 'web-streams-polyfill/dist/polyfill';
1919

20-
import {getV2BrowserResponse, getV3BrowserResponse} from '@aws-sdk/test-utils';
20+
import {getBrowserResponse} from '@aws-sdk/test-utils';
2121

2222
const App: () => Node = () => {
23-
const [v2Response, setV2Response] = useState('');
24-
const [v3Response, setV3Response] = useState('');
23+
const [response, setResponse] = useState('');
2524

26-
const fetchV2Response = async () => {
25+
const fetchResponse = async () => {
2726
try {
28-
const v2Response = await getV2BrowserResponse();
29-
setV2Response(JSON.stringify(v2Response, null, 2));
27+
const response = await getBrowserResponse();
28+
setResponse(JSON.stringify(response, null, 2));
3029
} catch (err) {
3130
console.error(serializeError(err));
32-
setV2Response(`Error: ${err}. Check console for more details.`);
33-
}
34-
};
35-
36-
const fetchV3Response = async () => {
37-
try {
38-
const v3Response = await getV3BrowserResponse();
39-
setV3Response(JSON.stringify(v3Response, null, 2));
40-
} catch (err) {
41-
console.error(serializeError(err));
42-
setV3Response(`Error: ${err}. Check console for more details.`);
31+
setResponse(`Error: ${err}. Check console for more details.`);
4332
}
4433
};
4534

4635
return (
4736
<View style={styles.container}>
4837
<View style={styles.sectionContainer}>
49-
<Text style={styles.sectionTitle}>AWS SDK for JavaScript (v2):</Text>
50-
<Button title="Call with v2" onPress={fetchV2Response} />
51-
<TextInput
52-
style={styles.sectionDescription}
53-
multiline={true}
54-
placeholder="v2 response will be populated here"
55-
value={v2Response}
56-
/>
57-
</View>
58-
<View style={styles.sectionContainer}>
59-
<Text style={styles.sectionTitle}>AWS SDK for JavaScript (v3):</Text>
60-
<Button title="Call with v3" onPress={fetchV3Response} />
38+
<Text style={styles.sectionTitle}>AWS SDK for JavaScript:</Text>
39+
<Button title="Click to make a call" onPress={fetchResponse} />
6140
<TextInput
6241
style={styles.sectionDescription}
6342
multiline={true}
64-
placeholder="v3 response will be populated here"
65-
value={v3Response}
43+
placeholder="Response will be populated here"
44+
value={response}
6645
/>
6746
</View>
6847
</View>

packages/utils/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"dependencies": {
88
"@aws-sdk/client-cognito-identity": "^3.540.0",
99
"@aws-sdk/client-dynamodb": "^3.540.0",
10-
"@aws-sdk/credential-provider-cognito-identity": "^3.540.0",
11-
"aws-sdk": "^2.1588.0"
10+
"@aws-sdk/credential-provider-cognito-identity": "^3.540.0"
1211
},
1312
"author": {
1413
"name": "AWS SDK for JavaScript Team",

packages/utils/src/utils.js

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,16 @@
1-
import AWS from "aws-sdk";
2-
31
import { fromCognitoIdentityPool } from "@aws-sdk/credential-provider-cognito-identity";
42
import { CognitoIdentityClient } from "@aws-sdk/client-cognito-identity";
53
import { DynamoDB } from "@aws-sdk/client-dynamodb";
64

75
import { REGION, IDENTITY_POOL_ID } from "./config.js";
86

9-
export const getV2Response = async (clientParams) => {
10-
const client = new AWS.DynamoDB(clientParams);
11-
return client.listTables({ Limit: 1 }).promise();
12-
};
13-
14-
export const getV3Response = async (clientParams) => {
7+
export const getResponse = async (clientParams) => {
158
const client = new DynamoDB(clientParams);
169
return client.listTables({ Limit: 1 });
1710
};
1811

19-
export const getV2BrowserResponse = async () => {
20-
// Initialize the Amazon Cognito credentials provider
21-
AWS.config.region = REGION;
22-
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
23-
IdentityPoolId: IDENTITY_POOL_ID,
24-
});
25-
26-
return getV2Response({ region: REGION });
27-
};
28-
29-
export const getV3BrowserResponse = async () =>
30-
getV3Response({
12+
export const getBrowserResponse = async () =>
13+
getResponse({
3114
region: REGION,
3215
credentials: fromCognitoIdentityPool({
3316
client: new CognitoIdentityClient({

packages/web/src/index.js

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
getV2BrowserResponse,
3-
getV3BrowserResponse,
4-
} from "@aws-sdk/test-utils";
1+
import { getBrowserResponse } from "@aws-sdk/test-utils";
52

63
const getHTMLElement = (title, content) => {
74
const element = document.createElement("div");
@@ -20,24 +17,11 @@ const getHTMLElement = (title, content) => {
2017
return element;
2118
};
2219

23-
const componentV2 = async () => {
24-
const response = await getV2BrowserResponse();
25-
return getHTMLElement(
26-
"Data returned by v2:",
27-
JSON.stringify(response, null, 2)
28-
);
29-
};
30-
31-
const componentV3 = async () => {
32-
const response = await getV3BrowserResponse();
33-
34-
return getHTMLElement(
35-
"Data returned by v3:",
36-
JSON.stringify(response, null, 2)
37-
);
20+
const component = async () => {
21+
const response = await getBrowserResponse();
22+
return getHTMLElement("Data returned:", JSON.stringify(response, null, 2));
3823
};
3924

4025
(async () => {
41-
document.body.appendChild(await componentV2());
42-
document.body.appendChild(await componentV3());
26+
document.body.appendChild(await component());
4327
})();

0 commit comments

Comments
 (0)