Need private packages and team management tools?Check out npm Teams »

kth-node-session

1.0.4 • Public • Published

kth-node-session Build Status

A Node.js module for setting up session middleware for Express.js apps.

Enforces certain defaults that should improve security related to sessions.

Available session options: https://www.npmjs.com/package/express-session

Available Redis options: https://www.npmjs.com/package/connect-redis

Usage

const express = require('express')
const session = require('kth-node-session')
 
const app = express()
 
const options = {
  // set to true to enable session storage in RedisStore
  // default is to use MemoryStore
  useRedis: false,
 
  // this is used as redis prefix and session cookie name
  // must be set here or as individual settings for redis (prefix) and session (name)
  key: 'node-app.sid',
 
  // https://www.npmjs.com/package/connect-redis
  redisOptions: {
    // ...
  },
 
  // https://www.npmjs.com/package/express-session
  sessionOptions: {
    // secret must be set!
    secret: 'my-secret-string',
 
    // this should not be set when enabling Redis
    // or if using the default value
    store: null
  }
}
 
app.use(session(options))

Keywords

none

Install

npm i kth-node-session

DownloadsWeekly Downloads

48

Version

1.0.4

License

MIT

Unpacked Size

4.44 kB

Total Files

4

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar