0.0.2 • Published 7 years ago

koa-generic-session-file2 v0.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

Koa Generic Session File store

it just koa-generic-session-file bug fix version

This plugin for koa-generic-session is for when you just want basic file-based session stores. It's useful when you want persistent sessions for a small number of users without having to spin up an instance of Redis or Mongo.

Installation

Install via npm:

npm install koa-generic-session-file2

Usage

Just plug it into koa-generic-session as you would with the other generic stores. For example:

var Koa = require("koa");
var session = require("koa-generic-session");
var FileStore = require("koa-generic-session-file2");

var app = new Koa();
app.keys = ["keys", "keykeys"];

app.use(session({
  store: new FileStore()
}));

By default, the middleware will store session files in a directory called "sessions" relative to your application's cwd. You can customise this path in the options.

Options

You can customise the behaviour of the store in a few small ways by passing options in when instantiating FileStore:

  • sessionDirectory: use this if you want to store your session files in a custom location. It should be a path relative to your process.cwd() path, or an absolute path.
app.use(session({
  store: new FileStore({
    sessionDirectory: "/absolute/path/to/my/sessions"
  })
}));