How to use connect-session-knex - 2 common examples

To help you get started, we’ve selected a few connect-session-knex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rafaelalmeidatk / twitter-fullstack-clone / packages / server / src / app.js View on Github external
app.use(bodyParser.urlencoded({ extended: false }));
    app.use(bodyParser.json());
    app.use(cors({ origin: [process.env.FRONTEND_URL, 'http://localhost:3000'], credentials: true }));

    //--------------------
    // Cookies settings

    const cookieSettings = {
      httpOnly: true,
      secure: IS_PRODUCTION,
    };

    //--------------------
    // Sessions

    const KnexSessionStore = connectSessionKnex(session);
    const store = new KnexSessionStore({ knex });
    app.use(
      session({
        cookie: cookieSettings,
        secret: 'test',
        resave: false,
        saveUninitialized: false,
        store,
      })
    );

    //--------------------
    // Auth

    app.use(auth({ cookieSettings }));
github azchatlanin / pepelats.pro / server / index.js View on Github external
import express from 'express'
import bodyParser from 'body-parser'
import path from 'path'
import morgan from 'morgan'
import Debug from 'debug'
import session from 'express-session'
import KnexSessionStore from 'connect-session-knex'
import db from './controllers/config/knex'
import devOptions from './controllers/config/dev.serv.opt'
import history from 'connect-history-api-fallback'
import serveStatic from 'serve-static'
// routes
import auth from './routes/auth'

const SessionStore = KnexSessionStore(session)
const store = new SessionStore({
  knex: db,
  tablename: 'session'
})
const debug = Debug('server:app')
const port = process.env.PORT || 5000
const app = express()

app.use(bodyParser.json())
app.use(morgan('dev'))
app.use(history())
app.use(session({
  secret: 'secret',
  saveUninitialized: true,
  resave: true,
  store: store

connect-session-knex

A knex.js session store for Express and Connect

ISC
Latest version published 6 months ago

Package Health Score

71 / 100
Full package analysis

Popular connect-session-knex functions