Skip to content
session-redis / 0.5.0

session-redis 0.5.0

Install from the command line:
Learn more about npm packages
$ npm install @curveball/session-redis@0.5.0
Install via package.json:
"@curveball/session-redis": "0.5.0"

About this version

Curveball Redis Session Middleware

Greenkeeper badge

This package adds support for sessions to the [Curveball][https://github.com/curveball/] framework. The

session store is backed by Redis, therefore having an accessable Redis server is a prerequisite.

Installation

npm install @curveball/session-redis

Getting started

Adding the middleware

import session from '@curveball/session';
import { RedisStore } from '@curveball/session-redis';

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

This will add the redis session store to curveball. Using the redis store without any options will attempt to connect to a local Redis server using default connection details.

Here is another example with more options:

import session from '@curveball/session';
import RedisStore from '@curveball/session-redis';

app.use(session({
  store: new RedisStore({
    prefix: 'mysess',
    clientOptions: {
      host: 'myhost.redis',
      port: 1234,
      ...
    },
  }),
  cookieName: 'MY_SESSION',
  expiry: 7200
});

clientOptions is the set of options for the Redis client. The list of available clientOptions can be found on the NodeRedis/node_redis repository.

Instead of passing clientOptions, it's also possible to pass a fully setup isntance of RedisClient. This can be useful if the same connection should be re-used by a different part of your application:

import session from '@curveball/session';
import RedisStore from '@curveball/session-redis';
import { RedisClient } from 'redis';

const redis = new RedisClient({
  host: 'myhost.redis',
  port: 1234,
});

app.use(session({
  store: new RedisStore({
    prefix: 'mysess',
    client: redis
  })
  cookieName: 'MY_SESSION',
  expiry: 7200
});

Details


Assets

  • session-redis-0.5.0.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0

Recent versions

View all