Skip to content

Commit

Permalink
Test_RailWay
Browse files Browse the repository at this point in the history
  • Loading branch information
diochos committed Jun 27, 2024
1 parent edfd447 commit 34777dd
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
15 changes: 15 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const PORT = process.env.PORT || 3000;
const DB_HOST = process.env.DB_HOST || 'localhost';
const DB_NAME = process.env.DB_NAME || 'MiBaseDeDatos';
const DB_PASSWORD = process.env.DB_PASSWORD || 'RiasSempai123';
const DB_USER = process.env.DB_USER || 'root';
const DB_PORT = process.env.DB_PORT || 3306;

module.exports = {
PORT,
DB_HOST,
DB_NAME,
DB_PASSWORD,
DB_USER,
DB_PORT
};
23 changes: 16 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
const {
PORT,
DB_HOST,
DB_NAME,
DB_PASSWORD,
DB_USER,
DB_PORT
} = require('./config');

const express = require('express');
const app = express();
const mysql = require('mysql');
const path = require('path');
const bodyParser = require('body-parser');

const port = process.env.PORT || 3000;

const db = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'RiasSempai123',
database: 'MiBaseDeDatos'
host: DB_HOST,
user: DB_USER,
password: DB_PASSWORD,
port: DB_PORT,
database: DB_NAME
});

db.connect((err) => {
Expand Down Expand Up @@ -53,6 +62,6 @@ app.post('/actualizar_valor', (req, res) => {
});
});

app.listen(port, () => {
console.log(`Servidor escuchando en http://localhost:${port}`);
app.listen(PORT, () => {
console.log(`Servidor escuchando en http://localhost:${PORT}`);
});
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "caribbeanhousestudio_web",
"version": "1.0.0",
"main": "server.js",
"main": "index.js",
"scripts": {
"start": "node server.js"
"start": "node index.js"
},
"keywords": [],
"author": "",
Expand Down

0 comments on commit 34777dd

Please sign in to comment.