@@ -4,7 +4,7 @@ import bodyParser from 'body-parser';
44import cookieParser from 'cookie-parser' ;
55import cors from 'cors' ;
66import session from 'express-session' ;
7- import connectMongo from 'connect-mongo' ;
7+ import MongoStore from 'connect-mongo' ;
88import passport from 'passport' ;
99import path from 'path' ;
1010import basicAuth from 'express-basic-auth' ;
@@ -32,7 +32,6 @@ import { renderIndex } from './views/index';
3232import { get404Sketch } from './views/404Page' ;
3333
3434const app = new Express ( ) ;
35- const MongoStore = connectMongo ( session ) ;
3635
3736app . get ( '/health' , ( req , res ) => res . json ( { success : true } ) ) ;
3837
@@ -76,14 +75,12 @@ app.use(cookieParser());
7675
7776mongoose . set ( 'strictQuery' , true ) ;
7877
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+ } ) ;
8784
8885app . use (
8986 session ( {
@@ -97,9 +94,9 @@ app.use(
9794 secure : false ,
9895 maxAge : 1000 * 60 * 60 * 24 * 28 // 4 weeks in milliseconds
9996 } ,
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
103100 } )
104101 } )
105102) ;
0 commit comments