JSPM

express-sequelize-session

0.4.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 205
  • Score
    100M100P100Q119382F
  • License MIT

Express Sequelize session store

Package Exports

  • express-sequelize-session

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (express-sequelize-session) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Express Sequelize session store

Build Status

Usage

Express 3.x


    # load and init express app
    express = require 'express'
    app = express()

    # load and init Sequelize connection
    Sequelize = require 'sequelize'
    sequelize = new Sequelize 'db.name', 'db.user', 'db.pass'

    # load and create session store
    Store = require('express-sequelize-session') express.session.Store
    app.use express.session
      key: 'sid'
      secret: 'MyAwesomeAppSessionSecret'
      store: new Store sequelize

The Express 3.x sample application shows a complete setup to get started.

Express 4.x


    # load and init express app
    express = require 'express'
    expressSession = require 'express-session'
    app = express()

    # load and init Sequelize connection
    Sequelize = require 'sequelize'
    sequelize = new Sequelize 'db.name', 'db.user', 'db.pass'

    # load and create session store
    Store = require('express-sequelize-session') expressSession.Store
    app.use expressSession
      name: 'sid'
      secret: 'MyAwesomeAppSessionSecret'
      store: new Store sequelize
      resave: false
      saveUninitialized: true

The Express 4.x sample application shows a complete setup to get started.

Custom Schema

use individual table name with optional string column


    store = new Store sequelize, 'http_session_table',
      optional:
        type: Sequelize.STRING
        allowNull: true

reference other entities


    # define user table
    User = sequelize.define 'user',
      login:
        type: Sequelize.STRING
        allowNull: false
        unique: true
      password:
        type: Sequelize.STRING
        allowNull: false

    # associate session user
    User.belongsTo store.Session, foreignKeyConstraint: true

Development

build and test it

    express-sequelize-session git:(master) ✗ cake
    Cakefile defines the following tasks:

    cake build                # build coffee
    cake coverage             # run coverage
    cake lint                 # run lint
    cake spec                 # run specifications