From aa5cfcaa2b6b991ce8b13c3fac44d96abd748b8e Mon Sep 17 00:00:00 2001
From: Jesus Galaz <jesusgalazr@icloud.com>
Date: Sun, 13 Oct 2024 14:17:36 +0200
Subject: [PATCH] Also fixing wrong version of this file

---
 server.js | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/server.js b/server.js
index a48072d..96eccca 100644
--- a/server.js
+++ b/server.js
@@ -1,21 +1,31 @@
-// server.js
 const express = require('express');
 const path = require('path');
-const connectDB = require('./mongodb'); // Import the MongoDB connection
+const connectDB = require('./mongodb');
+const session = require('express-session');
 
 const app = express();
 
 // Middleware
-app.use(express.json()); // Use express' built-in body-parser for JSON
-app.use(express.static(path.join(__dirname, 'public'))); // Serve static files
+app.use(express.json());
+app.use(express.static(path.join(__dirname, 'public')));
 
-// Connect to MongoDB
-connectDB(); // Call the function to establish the database connection
+// Configuración de la sesión
+app.use(
+  session({
+    secret: 'session_secret',
+    resave: false,
+    saveUninitialized: false,
+    cookie: { secure: false }
+  })
+);
 
-// Routes
+// Conectar a MongoDB
+connectDB();
+
+// Rutas
 app.use('/api/todos', require('./routes/todos'));
 app.use('/api/users', require('./routes/users'));
 
-// Start the server
+// Iniciar el servidor
 const PORT = process.env.PORT || 3000;
 app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
-- 
GitLab