@@ -4,7 +4,7 @@ import bodyParser from 'body-parser';
4
4
import cookieParser from 'cookie-parser' ;
5
5
import cors from 'cors' ;
6
6
import session from 'express-session' ;
7
- import connectMongo from 'connect-mongo' ;
7
+ import MongoStore from 'connect-mongo' ;
8
8
import passport from 'passport' ;
9
9
import path from 'path' ;
10
10
import basicAuth from 'express-basic-auth' ;
@@ -32,7 +32,6 @@ import { renderIndex } from './views/index';
32
32
import { get404Sketch } from './views/404Page' ;
33
33
34
34
const app = new Express ( ) ;
35
- const MongoStore = connectMongo ( session ) ;
36
35
37
36
app . get ( '/health' , ( req , res ) => res . json ( { success : true } ) ) ;
38
37
@@ -76,14 +75,12 @@ app.use(cookieParser());
76
75
77
76
mongoose . set ( 'strictQuery' , true ) ;
78
77
79
- const clientPromise = mongoose
80
- . connect ( mongoConnectionString , {
81
- useNewUrlParser : true ,
82
- useUnifiedTopology : true ,
83
- serverSelectionTimeoutMS : 30000 , // 30 seconds timeout
84
- socketTimeoutMS : 45000 // 45 seconds timeout
85
- } )
86
- . then ( ( m ) => m . connection . getClient ( ) ) ;
78
+ // TODO: update mongodb connection for other scripts
79
+
80
+ mongoose . connect ( mongoConnectionString , {
81
+ serverSelectionTimeoutMS : 30000 , // 30 seconds timeout
82
+ socketTimeoutMS : 45000 // 45 seconds timeout
83
+ } ) ;
87
84
88
85
app . use (
89
86
session ( {
@@ -97,9 +94,9 @@ app.use(
97
94
secure : false ,
98
95
maxAge : 1000 * 60 * 60 * 24 * 28 // 4 weeks in milliseconds
99
96
} ,
100
- store : new MongoStore ( {
101
- clientPromise ,
102
- autoReconnect : true
97
+ store : MongoStore . create ( {
98
+ mongoUrl : mongoConnectionString ,
99
+ ttl : 1000 * 60 * 60 * 24 * 28 // 4 weeks in milliseconds to match cookie maxAge
103
100
} )
104
101
} )
105
102
) ;
0 commit comments