diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/config.js b/config.js new file mode 100644 index 0000000..105fff8 --- /dev/null +++ b/config.js @@ -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 +}; diff --git a/index.js b/index.js index 13b8186..600c7d1 100644 --- a/index.js +++ b/index.js @@ -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) => { @@ -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}`); }); diff --git a/package.json b/package.json index 5ac9a52..deaa115 100644 --- a/package.json +++ b/package.json @@ -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": "",