Metzploreur/config/session.js
clement callaert 69ca3cd3f7 Version 1
2023-11-01 02:59:06 +01:00

32 lines
618 B
JavaScript

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
}