From 90e9c8ed559d37053703ea4bd263a8186aac3aaa Mon Sep 17 00:00:00 2001 From: DiegoGDPR <106365170+diochos@users.noreply.github.com> Date: Mon, 24 Jun 2024 20:19:48 -0600 Subject: [PATCH] Test Vercel y Node.js --- server.js => index.js | 18 +++++++++++++++--- package-lock.json | 3 +-- vercel.json | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) rename server.js => index.js (63%) create mode 100644 vercel.json diff --git a/server.js b/index.js similarity index 63% rename from server.js rename to index.js index e5fc193..08caecf 100644 --- a/server.js +++ b/index.js @@ -1,5 +1,8 @@ const express = require('express'); const app = express(); + +const port = process.env.PORT || 3000; + const mysql = require('mysql'); const path = require('path'); @@ -20,7 +23,11 @@ app.set('views', path.join(__dirname, 'src/views')); app.use(express.static(path.join(__dirname, 'src'))); -app.get('/seguimiento', (req, res) => { +app.get("/", (req, res) => { + res.sendFile(path.join(__dirname, 'src', 'index.html')); +}); + +app.get("/seguimiento", (req, res) => { db.query('SELECT valor FROM Datos LIMIT 1', (err, results) => { if (err) throw err; const etapa = results[0].valor; @@ -28,6 +35,11 @@ app.get('/seguimiento', (req, res) => { }); }); -app.listen(3000, () => { - console.log('Servidor escuchando en http://localhost:3000'); +app.get("/empleadoTest", (req, res) => { + res.sendFile(path.join(__dirname, 'src', 'empleadoTest.html')); +}); +/* +app.listen(port, () => { + console.log(`Servidor escuchando en http://localhost:${port}`); }); +*/ \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f6db8b1..3ff0538 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,8 +13,7 @@ "ejs": "^3.1.10", "express": "^4.19.2", "mysql": "^2.18.1" - }, - "devDependencies": {} + } }, "node_modules/accepts": { "version": "1.3.8", diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..a07fcd4 --- /dev/null +++ b/vercel.json @@ -0,0 +1,15 @@ +{ + "builds": [ + { + "src": "./index.js", + "use": "@vercel/node" + } + ], + "routes": [ + { + "src": "/(.*)", + "dest": "/" + } + ] + } + \ No newline at end of file