Skip to content

Commit

Permalink
backend(10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bibiing committed Dec 17, 2024
1 parent 5dc9b00 commit 168c617
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
54 changes: 54 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"axios": "^1.7.9",
"bcrypt": "^5.1.1",
"bcryptjs": "^2.4.3",
"connect-mongo": "^5.1.0",
"cookie-session": "^2.1.0",
"cors": "^2.8.5",
"date-fns": "^4.1.0",
Expand Down
11 changes: 7 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import helmet from "helmet";
import cors from "cors";
import session from "express-session";
import passport from "passport";
import MongoStore from "connect-mongo";

// Import route handlers
import setupAuthRoutes from "./src/routes/authGoogle.js";
Expand Down Expand Up @@ -47,10 +48,7 @@ app.use(
// Database Connection
const connectDB = async () => {
try {
await mongoose.connect(process.env.MONGODB_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
await mongoose.connect(process.env.MONGODB_URI);
console.log("MongoDB connected successfully");
} catch (error) {
console.error("MongoDB connection error:", error);
Expand Down Expand Up @@ -78,6 +76,11 @@ app.use(
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: false,
store: MongoStore.create({
mongoUrl: process.env.MONGODB_URI,
autoRemove: "interval",
autoRemoveInterval: 10, // Minutes
}),
cookie: {
maxAge: 24 * 60 * 60 * 1000,
secure: process.env.NODE_ENV === "production",
Expand Down

0 comments on commit 168c617

Please sign in to comment.