1.0.0-beta.1 • Published 7 years ago

koa-session-mongoose-store v1.0.0-beta.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Koa Session Mongoose Store

This code is just a beta. It needs more testing before using in production systems.

This package is for storing sessions in MongoDB using the koa-session module and mongoose.

Install

npm install --save koa-session-mongoose-store

Usage

To use this module, load it as part of the settings for koa-session.

const Koa = require('koa');
const session = require('koa-session');
const MongooseStore = require('koa-session-mongoose-store');

const app = new Koa();
app.use(session({
    store: new MongooseStore()
}), app);

By default, the sessions stored in MongoDB have an expire index set to delete the record after one day of inactivity. To change that expiration time, pass the option to the store constructor:

new MongooseStore({ expires: 3600 }); // expire after one hour (time is in seconds)

If you change the Mongoose store expiration time, you will need to change the maxAge setting in the koa-session options to match.

1.0.0-beta.1

7 years ago