This repository has been archived by the owner on Oct 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace all aws-sdk v2 usages with aws sdk v3 clients
- Loading branch information
Showing
15 changed files
with
4,078 additions
and
3,361 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
const AWS = require('aws-sdk') | ||
const docClient = new AWS.DynamoDB.DocumentClient({ | ||
endpoint: process.env.DYNAMODB_ENDPOINT_URL | ||
}) | ||
const { DynamoDBClient } = require('@aws-sdk/client-dynamodb') | ||
const { | ||
DynamoDBDocumentClient, | ||
PutCommand | ||
} = require('@aws-sdk/lib-dynamodb') | ||
|
||
const dynamoClient = new DynamoDBClient({ endpoint: process.env.DYNAMODB_ENDPOINT_URL }) | ||
const docClient = DynamoDBDocumentClient.from(dynamoClient) | ||
|
||
/* | ||
[email protected] UserId: mock-auth-dGVzdGFjY291bnQxQGV4YW1wbGUuY29t | ||
|
@@ -40,11 +44,10 @@ async function run () { | |
await Promise.all( | ||
records.map(record => | ||
docClient | ||
.put({ | ||
.send(new PutCommand({ | ||
TableName: 'checklists', | ||
Item: record | ||
}) | ||
.promise() | ||
})) | ||
) | ||
) | ||
console.log('Finished querying records') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
const AWS = require('aws-sdk') | ||
const docClient = new AWS.DynamoDB.DocumentClient({ | ||
endpoint: process.env.DYNAMODB_ENDPOINT_URL | ||
}) | ||
const { DynamoDBClient } = require('@aws-sdk/client-dynamodb') | ||
const { | ||
BatchGetCommand, | ||
DynamoDBDocumentClient, | ||
QueryCommand | ||
} = require('@aws-sdk/lib-dynamodb') | ||
|
||
const tableName = 'checklists' | ||
const dynamoClient = new DynamoDBClient({ endpoint: process.env.DYNAMODB_ENDPOINT_URL }) | ||
const docClient = DynamoDBDocumentClient.from(dynamoClient) | ||
|
||
const TableName = 'checklists' | ||
|
||
/* | ||
[email protected] UserId: mock-auth-dGVzdGFjY291bnQxQGV4YW1wbGUuY29t | ||
|
@@ -13,8 +18,8 @@ async function run () { | |
console.log('Querying records') | ||
const userId = 'mock-auth-dGVzdGFjY291bnQyQGV4YW1wbGUuY29t' // testaccount2 | ||
const lists = (await docClient | ||
.query({ | ||
TableName: tableName, | ||
.send(new QueryCommand({ | ||
TableName, | ||
ProjectionExpression: | ||
'listId, #nm, #description, createdAt, sharedListOwner, userId', | ||
KeyConditionExpression: 'userId = :userId', | ||
|
@@ -25,8 +30,7 @@ async function run () { | |
ExpressionAttributeValues: { | ||
':userId': userId | ||
} | ||
}) | ||
.promise()).Items | ||
}))).Items | ||
|
||
console.log({ lists }) | ||
const sharedListKeys = lists | ||
|
@@ -36,9 +40,9 @@ async function run () { | |
// Next, find the actual records for shared lists with name, description and createdAt values | ||
if (sharedListKeys.length) { | ||
const sharedLists = (await docClient | ||
.batchGet({ | ||
.send(new BatchGetCommand({ | ||
RequestItems: { | ||
[tableName]: { | ||
[TableName]: { | ||
Keys: sharedListKeys, | ||
ProjectionExpression: | ||
'listId, #nm, #description, createdAt, userId', | ||
|
@@ -48,8 +52,7 @@ async function run () { | |
} | ||
} | ||
} | ||
}) | ||
.promise()).Responses[tableName] | ||
}))).Responses[TableName] | ||
// Merge values from actual records into shared list records | ||
console.log('sharedlists***', { sharedLists }) | ||
sharedLists.forEach(sharedList => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters