Version 1
This commit is contained in:
parent
2a59531d32
commit
69ca3cd3f7
32
config/session.js
Normal file
32
config/session.js
Normal 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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue