lambder 1.0.121 → 1.0.122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +21 -17
- package/deploy.sh +5 -0
- package/package.json +1 -1
package/Readme.md
CHANGED
|
@@ -37,8 +37,8 @@ const lambder = new Lambder({
|
|
|
37
37
|
|
|
38
38
|
// Enable session
|
|
39
39
|
lambder.enableDdbSession({
|
|
40
|
-
tableName: "website-session",
|
|
41
|
-
tableRegion: "us-east-1",
|
|
40
|
+
tableName: "website-session", // DynamoDB Table Name
|
|
41
|
+
tableRegion: "us-east-1", // DynamoDB Table Region
|
|
42
42
|
sessionSalt: "8p6Vt+4b1w3N8d/dcJ47QF3DRkp9koFg0G" // Change salt
|
|
43
43
|
});
|
|
44
44
|
|
|
@@ -221,13 +221,22 @@ lambder.addModule(async (lambder: Lambder): Promise<void> => {
|
|
|
221
221
|
You can enable session tracking by:
|
|
222
222
|
|
|
223
223
|
```typescript
|
|
224
|
-
// Enable session
|
|
224
|
+
// Enable sessions using a dynamodb session table
|
|
225
225
|
lambder.enableDdbSession({
|
|
226
|
-
tableName: "website-session",
|
|
227
|
-
tableRegion: "us-east-1",
|
|
226
|
+
tableName: "website-session", // DynamoDB Table Name
|
|
227
|
+
tableRegion: "us-east-1", // DynamoDB Table Region
|
|
228
228
|
sessionSalt: "8p6Vt+4b1w3N8d/dcJ47QF3DRkp9koFg0G" // Change salt
|
|
229
229
|
});
|
|
230
230
|
```
|
|
231
|
+
#### DynamoDB Session Table Structure:
|
|
232
|
+
|
|
233
|
+
Session system is enabled by storing data in a DynamoDB session table.
|
|
234
|
+
|
|
235
|
+
- Primary Key: "pk"
|
|
236
|
+
- Sort Key: "sk"
|
|
237
|
+
- TTL Key: "expiresAt" (optional)
|
|
238
|
+
|
|
239
|
+
#### Session Controller
|
|
231
240
|
|
|
232
241
|
After you enable the session, you can access to the session controller:
|
|
233
242
|
|
|
@@ -235,26 +244,26 @@ After you enable the session, you can access to the session controller:
|
|
|
235
244
|
// Create session controller:
|
|
236
245
|
const sessionController = lambder.getSessionController(ctx);
|
|
237
246
|
|
|
238
|
-
|
|
247
|
+
// Type for sessionController
|
|
239
248
|
sessionController: {
|
|
240
|
-
async createSession(sessionKey, data, ttlInSeconds):
|
|
249
|
+
async createSession(sessionKey, data, ttlInSeconds): session
|
|
241
250
|
// Starts a new session and persists the session data to DDB.
|
|
242
251
|
|
|
243
|
-
async fetchSession():
|
|
252
|
+
async fetchSession(): session
|
|
244
253
|
// Fetch and validate if there is an existing session
|
|
245
254
|
// This is automatically done for addSessionRoute and addSessionApi
|
|
246
255
|
// Throws if session not found
|
|
247
256
|
|
|
248
|
-
async fetchSessionIfExists():
|
|
257
|
+
async fetchSessionIfExists(): session|null
|
|
249
258
|
// Runs fetchSession and returns the session if found. Otherwise return null
|
|
250
259
|
|
|
251
|
-
async updateSessionData(updatedData):
|
|
260
|
+
async updateSessionData(updatedData): updatedSession
|
|
252
261
|
// Updates the active sessions data and persist it to ddb.
|
|
253
262
|
|
|
254
|
-
async endSession():
|
|
263
|
+
async endSession():
|
|
255
264
|
// End session and delete from DDB.
|
|
256
265
|
|
|
257
|
-
async endSessionAll():
|
|
266
|
+
async endSessionAll():
|
|
258
267
|
// Ends and deletes all registered sessions for this sessionKey across all devices
|
|
259
268
|
}
|
|
260
269
|
*/
|
|
@@ -474,13 +483,8 @@ const loadPageData = async () => {
|
|
|
474
483
|
console.error("Failed to fetch page data:", error);
|
|
475
484
|
}
|
|
476
485
|
};
|
|
477
|
-
|
|
478
486
|
```
|
|
479
487
|
|
|
480
|
-
## Advanced Configuration
|
|
481
|
-
|
|
482
|
-
Lambder is designed to be flexible and extensible, allowing for customized behaviors through hooks and custom error handling mechanisms.
|
|
483
|
-
|
|
484
488
|
## Contributing
|
|
485
489
|
|
|
486
490
|
Contributions are welcome! Especially for documentation. If you have an idea for an improvement or have found a bug, please open an issue or submit a pull request.
|
package/deploy.sh
CHANGED