Version 1

This commit is contained in:
clement callaert 2023-11-01 02:59:06 +01:00
parent 2a59531d32
commit 69ca3cd3f7

32
config/session.js Normal file
View file

@ -0,0 +1,32 @@
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
}