Skip to content

Commit 391632e

Browse files
feat(DynamoStore): the region can be explicitly defined when creating a new DynamoStore instance
1 parent b6d8f0f commit 391632e

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
"moment-es6": "^1.0.0",
130130
"reflect-metadata": "^0.1.10",
131131
"rxjs": "^5.4.3",
132-
"ts-log-debug": "^3.0.0",
133132
"uuid": "^3.1.0"
134133
}
135134
}

src/dynamo/dynamo-rx.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ export class DynamoRx {
1010
readonly dynamoDb: DynamoDB
1111
readonly sessionValidityEnsurer: SessionValidityEnsurer
1212

13-
private readonly logger: Logger
14-
constructor(sessionValidtyEnsurer: SessionValidityEnsurer) {
13+
constructor(sessionValidityEnsurer: SessionValidityEnsurer, awsRegion?: string) {
1514
// this.logger = new Logger(() => LogLevel.DEBUG, 'DynamoDbService');
1615

1716
// create the actual dynamo db client
18-
this.dynamoDb = new DynamoDB()
19-
this.sessionValidityEnsurer = sessionValidtyEnsurer
17+
if (awsRegion) {
18+
this.dynamoDb = new DynamoDB()
19+
} else {
20+
this.dynamoDb = new DynamoDB({ region: awsRegion })
21+
}
22+
this.sessionValidityEnsurer = sessionValidityEnsurer
2023
}
2124

2225
updateAwsConfigCredentials(newConfig: AWS.Config): void {

src/dynamo/dynamo-store.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ export class DynamoStore<T> {
2424

2525
constructor(
2626
private modelClazz: ModelConstructor<T>,
27+
awsRegion?: string,
2728
tableNameResolver: TableNameResolver = DEFAULT_TABLE_NAME_RESOLVER,
2829
sessionValidityEnsurer: SessionValidityEnsurer = DEFAULT_SESSION_VALIDITY_ENSURER
2930
) {
30-
this.dynamoRx = new DynamoRx(sessionValidityEnsurer)
31+
this.dynamoRx = new DynamoRx(sessionValidityEnsurer, awsRegion)
3132
this.tableName = tableNameResolver(MetadataHelper.get(this.modelClazz).modelOptions.tableName)
3233
}
3334

0 commit comments

Comments
 (0)