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 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}`));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment