DynamoDB Session Store
DynamoDB based session store for use with express-session. This allows sessions to be stored in an existing DynamoDB table and provides flexibilty for tables that contain range/sort keys.
Installation
- Make sure you have a
.npmrc
file with the proper auth token npm install @brightcove/dynamodb-sessionstore
Usage
const session = require('express-session');
const sessionStore = require('@brightcove/dynamodb-sessionstore');
const DynamoDBStore = sessionStore({ session });
...
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true,
store: new DynamoDBStore(options),
...
}));
Options
Param | Type | Description | Required |
---|
database.table | string | Table name | yes |
database.endpoint | string | The endpoint/url of the database. Only required locally | local only |
database.region | string | The AWS region | yes |
getKey | function | A function that should accept a session ID and return an object containing the primary key and range/sort key (if necessary) for the session item | no |
expires | number | How long the default session should last (in milliseconds).By default it's 1 day | no |
updateTTL | boolean | Determines whether to enable the TimeToLiveSpecification on the table at initialization | no |