Skip to content

Commit c92604b

Browse files
authored
Add custom endpoint option to DynamoDB storage adapter (#120)
* add custom endpoint option to dynamostorage provider * Adds support for a custom DynamoDB endpoint which enables use of a amazon/dynamodb-local container. * add usage example
1 parent 2de6dc9 commit c92604b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

.changeset/young-tips-argue.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@openauthjs/openauth": patch
3+
---
4+
5+
Adds support for a custom DynamoDB endpoint which enables use of a amazon/dynamodb-local container.
6+
7+
Usabe example:
8+
9+
```ts
10+
storage: DynamoStorage({
11+
table: 'openauth-users',
12+
endpoint: 'http://localhost:8000',
13+
}),
14+
```

packages/openauth/src/storage/dynamo.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ export interface DynamoStorageOptions {
4747
* The sort key column name.
4848
*/
4949
sk?: string
50+
/**
51+
* Endpoint URL for the DynamoDB service. Useful for local testing.
52+
* @default "https://dynamodb.{region}.amazonaws.com"
53+
*/
54+
endpoint?: string
5055
}
5156

5257
/**
@@ -74,8 +79,9 @@ export function DynamoStorage(options: DynamoStorageOptions): StorageAdapter {
7479

7580
async function dynamo(action: string, payload: any) {
7681
const client = await c
82+
const endpoint = options.endpoint || `https://dynamodb.${client.region}.amazonaws.com`
7783
const response = await client.fetch(
78-
`https://dynamodb.${client.region}.amazonaws.com`,
84+
endpoint,
7985
{
8086
method: "POST",
8187
headers: {

0 commit comments

Comments
 (0)