npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

koa-session-dynamodb-store

v1.1.1

Published

The DynamoDB extension store for koa-session.

Downloads

31

Readme

koa-session-dynamodb-store

NPM version npm download

It is extension of koa-session that uses DynamoDB as session store inspired by dynamodb-store.

The project uses the following stack:

  • ES2017
  • Babel
  • Eslint with AirBnB style
  • Yarn
  • Flow

Installation

yarn add koa-session-dynamodb-store or npm install --save koa-session-dynamodb-store

Usage

Usage within koa:

const koaSession = require("koa-session");
const DynamoDBStore = require('koa-session-dynamodb-store');

const options = {
  table: {
    autoCreate: true // You should set this option to true if you want to automatically create a DynamoDB table for your session.
  }
}

app.use(koaSession({
    store: new DynamoDBStore(options),
    ...
}, app));

Usage within dynamodb-local:

const koaSession = require("koa-session");
const DynamoDBStore = require('koa-session-dynamodb-store');

const dynamoDBStoreOptions = {
  dynamoConfig: {
    region: 'local',
    endpoint: 'http://localhost:8000',
    accessKeyId: "dummyKey",
    secretAccessKey: "dummyKey"
  };
}
;
app.use(koaSession({
    store: new DynamoDBStore(dynamoDBStoreOptions),
    ...
}, app));

Options

{
  "table": {
    "name": "<NAME OF THE DYNAMO TABLE>", // default,  sessions
    "hashKey": "<NAME OF THE ID FIELD>", // default, sessionId
    "ttlKey": "<NAME OF THE DYNAMO TTL FIELD>", // default, expires
    "useTtlExpired": "<BOOLEAN>", // default, true
    "readCapacityUnits": "<NUMBER>", // default,: 5
    "writeCapacityUnits": "<NUMBER>" // default, 5
    "autoCreate": "<BOOLEAN>" // default, false
  },
  "dynamoConfig": {
    "accessKeyId": "<AWS ACCESS KEY>", // default
    "secretAccessKey": "<AWS ACCESS KEY SECRET>", // default
    "region": "<AWS REGION>", // default, If you are using the local version of DynamoDB, it must be a word that starts with local.
    "endpoint": "<DYNAMO ENDPOINT>" // default
  }
}

The table configuration is optional. The missing properties will be replaced by defaults.

Changing the table.ttlKey property may be ignored if the TTL attribute of DynamoDB is enabled. In this case, use the TTL property of DynamoDB as a priority.

If you have recently changed the value of table.useTtlExpired, the DynamoDB service will return an error. This will not work, please try again later.

Changing the readCapacityUnits and writeCapacityUnits frequently can also cause the DynamoDB service to return an error.

Please refer to the AWS DynamoDB Development Guide for details of the above error.

If option table.autoCreate is set to true the store will try to create a session table automatically during its initialization. Otherwise in order to initialize the table developer can explicitly call

await store.createTableIfDontExists();

at the right point according to an application architecture.

The dynamoConfig can be optional if the following environment variables are set: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION (which are present on Lambda Functions running on AWS). All properties from AWS.DynamoDB constructor can be informed in this structure.