From e0eed8ca357daa6056e26f0b2b37b0c4574fa94b Mon Sep 17 00:00:00 2001
From: Urata Daiki <7nohe@users.noreply.github.com>
Date: Mon, 16 Sep 2024 13:53:24 +0900
Subject: [PATCH 1/2] doc(sesison): add support for DynamoDB store
---
content/docs/basics/session.md | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/content/docs/basics/session.md b/content/docs/basics/session.md
index 600b2c8..fa4543f 100644
--- a/content/docs/basics/session.md
+++ b/content/docs/basics/session.md
@@ -14,6 +14,8 @@ You can manage user sessions inside your AdonisJS application using the `@adonis
- `redis`: The session data is stored inside a Redis database. The redis store is recommended for apps with large volumes of session data and can scale to multi-server deployments.
+- `dynamodb`: The session data is stored inside an Amazon DynamoDB table. The DynamoDB store is suitable for applications that require a highly scalable and distributed session store, especially when the infrastructure is built on AWS.
+
- `memory`: The session data is stored within a global memory store. The memory store is used during testing.
Alongside the inbuilt backend stores, you can also create and [register custom session stores](#creating-a-custom-session-store).
@@ -203,6 +205,19 @@ export default defineConfig({
redis: stores.redis({
connection: 'main'
})
+
+ dynamodb: stores.dynamodb({
+ clientConfig: {
+ // DynamoDB client config
+ // See: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-dynamodb/Interface/DynamoDBClientConfig/
+ // You can also set credentials using the environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.
+ // Also, you can set the region using the environment variable `AWS_REGION`.
+ },
+ tableName: 'Session', // The table name to store the sessions. The default is `Session`.
+ keyAttribute: 'key', // The attribute name for the session id, default is `key`.
+ valueAttribute: 'value', // The attribute name for the session value, default is `value`.
+ expiresAtAttribute: 'expires_at', // The attribute name for the session expiration, default is `expires_at`.
+ }),
}
// highlight-end
})
@@ -250,6 +265,18 @@ Make sure to first install and configure the [@adonisjs/redis](../database/redis
+
+
+ stores.dynamodb
+
+
+
+
+
+Define the configuration for the `dynamodb` store. The method accepts the `clientConfig`, `tableName`, `keyAttribute`, `valueAttribute`, and `expiresAtAttribute` properties.
+
+
+
---
@@ -257,7 +284,7 @@ Make sure to first install and configure the [@adonisjs/redis](../database/redis
### Updating environment variables validation
If you decide to use session stores other than the default one, make sure to also update the environment variables validation for the `SESSION_DRIVER` environment variable.
-We configure the `cookie` and the `redis` stores in the following example. Therefore, we should also allow the `SESSION_DRIVER` environment variable to be one of them.
+We configure the `cookie`, the `redis`, and the `dynamodb` stores in the following example. Therefore, we should also allow the `SESSION_DRIVER` environment variable to be one of them.
```ts
import { defineConfig, stores } from '@adonisjs/session'
From d36ff1465889b3ff299135bb6c9616f20f9764b1 Mon Sep 17 00:00:00 2001
From: Urata Daiki <7nohe@users.noreply.github.com>
Date: Sun, 22 Sep 2024 14:36:35 +0900
Subject: [PATCH 2/2] doc(session): remove `valueAttribute` and
`expiresAtAttribute` attribute
---
content/docs/basics/session.md | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/content/docs/basics/session.md b/content/docs/basics/session.md
index fa4543f..4ddf0b9 100644
--- a/content/docs/basics/session.md
+++ b/content/docs/basics/session.md
@@ -215,8 +215,6 @@ export default defineConfig({
},
tableName: 'Session', // The table name to store the sessions. The default is `Session`.
keyAttribute: 'key', // The attribute name for the session id, default is `key`.
- valueAttribute: 'value', // The attribute name for the session value, default is `value`.
- expiresAtAttribute: 'expires_at', // The attribute name for the session expiration, default is `expires_at`.
}),
}
// highlight-end
@@ -273,7 +271,7 @@ Make sure to first install and configure the [@adonisjs/redis](../database/redis
-Define the configuration for the `dynamodb` store. The method accepts the `clientConfig`, `tableName`, `keyAttribute`, `valueAttribute`, and `expiresAtAttribute` properties.
+Define the configuration for the `dynamodb` store. The method accepts the `clientConfig`, `tableName` and `keyAttribute` properties.