UNPKG

@cyclic.sh/session-store

Version:

Express middleware that stores sessions in DynamoDB tables for Cyclic apps.

31 lines (21 loc) 1 kB
const { DynamoDBDocumentClient } = require("@aws-sdk/lib-dynamodb") const { DynamoDBClient } = require("@aws-sdk/client-dynamodb") const REGION = process.env.AWS_REGION || 'us-east-2' const ddbClient = new DynamoDBClient({ region: REGION }); const marshallOptions = { // Whether to automatically convert empty strings, blobs, and sets to `null`. convertEmptyValues: true, // false, by default. // Whether to remove undefined values while marshalling. removeUndefinedValues: true, // false, by default. // Whether to convert typeof object to map attribute. convertClassInstanceToMap: true, // false, by default. }; const unmarshallOptions = { // Whether to return numbers as a string instead of converting them to native JavaScript numbers. wrapNumbers: false, // false, by default. }; const translateConfig = { marshallOptions, unmarshallOptions }; const docClient = DynamoDBDocumentClient.from(ddbClient, translateConfig); module.exports = { docClient }