Skip to content

Beginning an Adapter for msql2 promises to be used with express-session Store

Notifications You must be signed in to change notification settings

aljones15/express-sql-session-promise-adapter

Repository files navigation

express-sql-session-promise-adapter

note: this is no longer necessary sql session now supports promises default: promiseAdapter let's you use mysql2 promises with express-mysql-session

import promiseAdapter from 'express-session-mysql2-promise-adapter';
import express from 'express';
import session from 'express-session';
import SQLSession from 'express-mysql-session';
import mysqlPromise from 'mysql2/promise';


export let db = mysqlPromise.createConnection({
  host: '127.0.0.1',
  port: 3306,
  user: process.env.SESSION_DB_USER,
  password: process.env.SESSION_DB_PASSWORD,
  database: process.env.SESSION_DB,
  connectTimeout: 600
});

const port = 8085;
const SQLStore = SQLSession(session);
const sessionStore = new SQLStore({}, promiseAdapter(db));
const localSession = {
  store: sessionStore,
  secret: 'test_secret',
  resave: true,
  rolling: true,
  saveUninitialized: true,
  cookie: {
    maxAge: 99999,
    httpOnly: false
  }
};

About

Beginning an Adapter for msql2 promises to be used with express-session Store

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published