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

To help you get started, we’ve selected a few connect-mongodb-session 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 Coding-Coach / coding-coach-api / src / config / express.js View on Github external
);
app.use(
  morgan(
    '[:date[iso]] :date[web] :remote-addr - :remote-user :method :url :status[pretty] :response-time',
  ),
);
const sessionOptions = {
  resave: true,
  saveUninitialized: true,
  secret: process.env.RANDOM_TOKEN,
};

if (process.env.NODE_ENV === 'production') {
  const database = process.env.NODE_ENV === 'test' ? 'test' : 'coding-coach';
  const dbURI = process.env.MONGO_DB_URI || `mongodb://localhost/${database}`;
  const MongoDBStore = MongoDBSession(session);
  const store = new MongoDBStore({
    uri: dbURI,
    collection: 'app_sessions',
  });
  sessionOptions.store = store;
}

app.use(session(sessionOptions));
app.use(cors());

oauthInitialize(app);

routes(app);

export default app;
github soha-moosa / node-auth-kit / app.js View on Github external
import express from 'express';
import mongoose from 'mongoose';
import cors from 'cors';
import session from 'express-session';
import connectMongoDBSession from 'connect-mongodb-session';
import passport from 'passport';
import cookieParser from 'cookie-parser';

import authRoutes from './routes/auth';
import { isUser } from './middleware/auth-middleware';
import User from './models/user';

const app = express();
const MongoDBStore = connectMongoDBSession(session);

const store = new MongoDBStore({
  uri: process.env.MONGODB_URI,
  collection: 'sessions'
});

app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));

app.use(cookieParser(process.env.SECRET));
app.use(
  session({
    secret: process.env.SECRET,
    resave: false,
    saveUninitialized: false,

connect-mongodb-session

MongoDB session store for connect/express built by MongoDB

Apache-2.0
Latest version published 10 months ago

Package Health Score

61 / 100
Full package analysis

Popular connect-mongodb-session functions