Skip to content
Snippets Groups Projects
Commit aa5cfcaa authored by Jesus Galaz's avatar Jesus Galaz
Browse files

Also fixing wrong version of this file

parent 7b13998a
No related branches found
No related tags found
1 merge request!5User authentication implemented
// server.js
const express = require('express'); const express = require('express');
const path = require('path'); const path = require('path');
const connectDB = require('./mongodb'); // Import the MongoDB connection const connectDB = require('./mongodb');
const session = require('express-session');
const app = express(); const app = express();
// Middleware // Middleware
app.use(express.json()); // Use express' built-in body-parser for JSON app.use(express.json());
app.use(express.static(path.join(__dirname, 'public'))); // Serve static files app.use(express.static(path.join(__dirname, 'public')));
// Connect to MongoDB // Configuración de la sesión
connectDB(); // Call the function to establish the database connection 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/todos', require('./routes/todos'));
app.use('/api/users', require('./routes/users')); app.use('/api/users', require('./routes/users'));
// Start the server // Iniciar el servidor
const PORT = process.env.PORT || 3000; const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Server running on port ${PORT}`)); app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment