-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: create only one instance of DynamoDBDocumentClient
- Loading branch information
Showing
5 changed files
with
31 additions
and
70 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; | ||
import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb"; | ||
|
||
/** | ||
* Helper function to instantiate DynamoDB and Document client. | ||
* https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/dynamodb-example-document-client.html | ||
*/ | ||
export function connectToDynamo(): DynamoDBDocumentClient { | ||
return DynamoDBDocumentClient.from( | ||
new DynamoDBClient({ | ||
region: process.env.AWS_REGION ?? "ca-central-1", | ||
...(process.env.LOCAL_AWS_ENDPOINT && { endpoint: process.env.LOCAL_AWS_ENDPOINT }), | ||
}) | ||
); | ||
} | ||
export const dynamodbClient = DynamoDBDocumentClient.from( | ||
new DynamoDBClient({ | ||
region: process.env.AWS_REGION ?? "ca-central-1", | ||
...(process.env.LOCAL_AWS_ENDPOINT && { endpoint: process.env.LOCAL_AWS_ENDPOINT }), | ||
}) | ||
); |
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