-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.js
More file actions
23 lines (20 loc) · 722 Bytes
/
connect.js
File metadata and controls
23 lines (20 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const mongoose = require('mongoose');
const session = require('express-session');
const mongoStore = require('connect-mongo')(session);
const Config = require('./config');
var options = {
server: { socketOptions: { keepAlive: 1 } }
};
mongoose.connect(Config.db, { useNewUrlParser: true });
const connection = mongoose.connection;
connection.on('error', function(error){console.log('error:'+error.message)})
.on('disconnected', function(){console.log('disconnected')})
.once('open', function(){console.log('success');});
module.exports = (app) => {
app.use(session({
store: new mongoStore({ mongooseConnection: connection }),
secret: 'demo',
saveUninitialized: true,
resave: false
}));
}