From c4eeafa7f1ea7435e971b1c619420e5f165e4564 Mon Sep 17 00:00:00 2001 From: DavidAlejandroSaenzMeneses Date: Tue, 22 Feb 2022 22:58:46 -0500 Subject: [PATCH] Ajuste Build:demo --- config/config.json | 3 +++ index.js | 4 +--- package-lock.json | 14 -------------- package.json | 2 +- src/dataBase/connection.js | 13 +++---------- src/models/index.js | 5 +---- 6 files changed, 9 insertions(+), 32 deletions(-) diff --git a/config/config.json b/config/config.json index 4486360..45205a1 100644 --- a/config/config.json +++ b/config/config.json @@ -4,6 +4,7 @@ "password": "5b05b7717", "database": "library-t", "host": "127.0.0.1", + "logging": false, "dialect": "postgres", "define": { "timestamps": false @@ -14,6 +15,7 @@ "password": "5b05b7717", "database": "library-t", "host": "127.0.0.1", + "logging": false, "dialect": "postgres", "define": { "timestamps": false @@ -24,6 +26,7 @@ "password": "5b05b7717", "database": "library-t", "host": "127.0.0.1", + "logging": false, "dialect": "postgres", "define": { "timestamps": false diff --git a/index.js b/index.js index 7a696fe..ba722f3 100644 --- a/index.js +++ b/index.js @@ -3,9 +3,7 @@ const myRouter = require('./src/routes/index.js'); const sequelize = require('./src/dataBase/connection.js'); const cors = require('cors'); const app = express(); -require('dotenv').config(); -const environment = process.env; -const port = environment.SERVER_PORT; +const port = 3900; //CORS app.use(cors()); diff --git a/package-lock.json b/package-lock.json index 7842458..625db49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,6 @@ "dependencies": { "connect-multiparty": "^2.2.0", "cors": "^2.8.5", - "dotenv": "^16.0.0", "express": "^4.17.2", "luxon": "^2.3.0", "pg": "^8.7.3", @@ -651,14 +650,6 @@ "node": ">=8" } }, - "node_modules/dotenv": { - "version": "16.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz", - "integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q==", - "engines": { - "node": ">=12" - } - }, "node_modules/dottie": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.2.tgz", @@ -3268,11 +3259,6 @@ "is-obj": "^2.0.0" } }, - "dotenv": { - "version": "16.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz", - "integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q==" - }, "dottie": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.2.tgz", diff --git a/package.json b/package.json index 675604e..0812a90 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "index.js", "scripts": { "start": "nodemon index.js", + "build:demo":"npx sequelize-cli db:create && npx sequelize-cli db:migrate && npx sequelize-cli db:seed:all", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { @@ -20,7 +21,6 @@ "dependencies": { "connect-multiparty": "^2.2.0", "cors": "^2.8.5", - "dotenv": "^16.0.0", "express": "^4.17.2", "luxon": "^2.3.0", "pg": "^8.7.3", diff --git a/src/dataBase/connection.js b/src/dataBase/connection.js index e10d430..ef52655 100644 --- a/src/dataBase/connection.js +++ b/src/dataBase/connection.js @@ -1,13 +1,6 @@ const { Sequelize } = require('sequelize'); -require('dotenv').config(); -const environment = process.env; +var env = process.env.NODE_ENV || 'development'; +var config = require(__dirname + '/../../config/config.json')[env]; -const connection = (new Sequelize(environment.DB_NAME, environment.DB_USER, environment.DB_PASS, { - host: environment.DB_HOST, - dialect: 'postgres', - logging: false, - define: { - timestamps: false - } -})); +const connection = (new Sequelize(config.database, config.username, config.password, config)); module.exports = connection; \ No newline at end of file diff --git a/src/models/index.js b/src/models/index.js index 012d79a..7188265 100644 --- a/src/models/index.js +++ b/src/models/index.js @@ -6,11 +6,8 @@ var basename = path.basename(module.filename); var env = process.env.NODE_ENV || 'development'; var config = require(__dirname + '/../config/server-config.json')[env]; var db = {}; -if (config.use_env_variable) { -var sequelize = new Sequelize(process.env[config.use_env_variable]); -} else { var sequelize = new Sequelize(config.database, config.username, config.password, config); -} + fs .readdirSync(__dirname) .filter(function(file) {