Skip to content

Commit 5f7ff65

Browse files
committed
revert changes
1 parent 8d396b3 commit 5f7ff65

File tree

1 file changed

+25
-31
lines changed

1 file changed

+25
-31
lines changed

server/server.js

+25-31
Original file line numberDiff line numberDiff line change
@@ -76,38 +76,32 @@ app.use(cookieParser());
7676

7777
mongoose.set('strictQuery', true);
7878

79-
async function initializeSession() {
80-
try {
81-
const mongooseConnection = await mongoose.connect(mongoConnectionString, {
82-
useNewUrlParser: true,
83-
useUnifiedTopology: true,
84-
serverSelectionTimeoutMS: 30000, // 30 seconds timeout
85-
socketTimeoutMS: 45000 // 45 seconds timeout
86-
});
87-
88-
app.use(
89-
session({
90-
resave: true,
91-
saveUninitialized: false,
92-
secret: process.env.SESSION_SECRET,
93-
proxy: true,
94-
name: 'sessionId',
95-
cookie: {
96-
httpOnly: true,
97-
secure: false
98-
},
99-
store: new MongoStore({
100-
mongooseConnection: mongooseConnection.connection,
101-
autoReconnect: true
102-
})
103-
})
104-
);
105-
} catch (error) {
106-
console.error('Error connecting to the database:', error);
107-
}
108-
}
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());
10987

110-
initializeSession();
88+
app.use(
89+
session({
90+
resave: true,
91+
saveUninitialized: false,
92+
secret: process.env.SESSION_SECRET,
93+
proxy: true,
94+
name: 'sessionId',
95+
cookie: {
96+
httpOnly: true,
97+
secure: false
98+
},
99+
store: new MongoStore({
100+
clientPromise,
101+
autoReconnect: true
102+
})
103+
})
104+
);
111105

112106
app.use('/api/v1', requestsOfTypeJSON(), api);
113107
// This is a temporary way to test access via Personal Access Tokens

0 commit comments

Comments
 (0)