Git Product home page Git Product logo

connect-dynamodb's Introduction

Connect DynamoDB

connect-dynamodb is a DynamoDB session store backed by the aws-sdk

NPM NPM

Installation

$ npm install connect-dynamodb

Options

Rational defaults are set but can be overridden in the options object. Credentials and configuration are automatically loaded from environment variables or shared credentials but may optionally be passed through a JSON file or object. The client attribute is necessary for use with DynamoDB Local but can be left out if using DynamoDB with your AWS account.

  • One of the following if not using environment variables or shared credentials:
  • client Optional AWS DynamoDB object from new AWS.DynamoDB()
  • AWSRegion Optional AWS region (defaults to 'us-east-1', ignored if using AWSConfigPath or AWSConfigJSON)
  • table Optional DynamoDB server session table name (defaults to "sessions")
  • hashKey Optional hash key (defaults to "id")
  • prefix Optional key prefix (defaults to "sess")
  • reapInterval Optional session expiration in milliseconds (defaults to 10 minutes)

Usage

var options = {
    // Optional DynamoDB table name, defaults to 'sessions'
    table: 'myapp-sessions',

    // Optional path to AWS credentials and configuration file
    // AWSConfigPath: './path/to/credentials.json',

    // Optional JSON object of AWS credentials and configuration
    AWSConfigJSON: {
        accessKeyId: <YOUR_ACCESS_KEY_ID>,
        secretAccessKey: <YOUR_SECRET_ACCESS_KEY>,
        region: 'us-east-1'
    },

    // Optional client for alternate endpoint, such as DynamoDB Local
    client: new AWS.DynamoDB({ endpoint: new AWS.Endpoint('http://localhost:8000')}),

    // Optional clean up interval, defaults to 600000 (10 minutes)
    reapInterval: 86400000    // 1 day
};

With connect

var connect = require('connect');
var DynamoDBStore = require('connect-dynamodb')(connect);
connect()
    .use(connect.cookieParser())
    .use(connect.session({ store: new DynamoDBStore(options), secret: 'keyboard cat'}));

With express 3

var DynamoDBStore = require('connect-dynamodb')(express);
var app = express(
    express.cookieParser(),
    express.session({ store: new DynamoDBStore(options), secret: 'keyboard cat'});
);

With express 4

var app = express();
var session = require('express-session');
var DynamoDBStore = require('connect-dynamodb')({session: session});
app.use(session({store: new DynamoDBStore(options), secret: 'keyboard cat'}));

Contributors

Some people that have added features and fixed bugs in connect-dynamodb other than me.

Thanks!

License

connect-dynamodb is licensed under the MIT license.

Donations

I made this in my spare time, so if you find it useful you can donate at my BTC address: 13Bzg4reJJt43wU1QsPSCzyFZMLhJbRELA. Thank you very much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.