Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 3, 2023. It is now read-only.

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

License

NotificationsYou must be signed in to change notification settings

chalk-hwang/koa-session-dynamodb-store

Repository files navigation

NPM versionnpm download

It is extension ofkoa-session that usesDynamoDB as session store inspired bydynamodb-store.

The project uses the following stack:

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

Installation

yarn add koa-session-dynamodb-storeornpm install --save koa-session-dynamodb-store

Usage

Usage within koa:

constkoaSession=require("koa-session");constDynamoDBStore=require('koa-session-dynamodb-store');constoptions={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:newDynamoDBStore(options),    ...},app));

Usage within dynamodb-local:

constkoaSession=require("koa-session");constDynamoDBStore=require('koa-session-dynamodb-store');constdynamoDBStoreOptions={dynamoConfig:{region:'local',endpoint:'http://localhost:8000',accessKeyId:"dummyKey",secretAccessKey:"dummyKey"};};app.use(koaSession({store:newDynamoDBStore(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  }}

Thetable configuration is optional. The missing properties will be replaced bydefaults.

Changing thetable.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 oftable.useTtlExpired, the DynamoDB service will return an error. This will not work, please try again later.

Changing thereadCapacityUnits andwriteCapacityUnits frequently can also cause the DynamoDB service to return an error.

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

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

awaitstore.createTableIfDontExists();

at the right point according to an application architecture.

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp