const express = require("express");
const path = require("path");
require("dotenv").config();
const { exec } = require("child_process");

const app = express();
const PORT = process.env.PORT || 3000;

app.use(express.json());

// Servir frontend desde /public
app.use(express.static(path.join(__dirname, "public")));

// Redirección para React Router
app.get("*", (req, res) => {
  const indexPath = path.join(__dirname, "public", "index.html");
  res.sendFile(indexPath);
});

app.listen(PORT, () => {
  console.log(`Servidor corriendo en el puerto ${PORT}`);
});