Metzploreur/config/session.js

33 lines
618 B
JavaScript
Raw Normal View History

2023-11-01 01:59:06 +00:00
const session = require("express-session");
const mongodbStore = require('connect-mongodb-session')
function createSessionStore (session) {
const MongoDBStore = mongodbStore(session);
const sessionStore = new MongoDBStore({
uri: 'mongodb://127.0.0.1:27017',
databaseName: 'BDE',
collection: 'sessions'
})
return sessionStore
}
function createSessionConfig (sessionStore) {
return {
secret: 'super-secret',
resave: false,
saveUninitialized: false,
store: sessionStore
}
}
module.exports = {
createSessionStore: createSessionStore,
createSessionConfig: createSessionConfig
}