diff --git a/.gitignore b/.gitignore index dea44f0..f0950c3 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ test-results/ # Mac bundle stuff *.dmg *.app +.env # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore # General diff --git a/users/index.js b/users/index.js index af75410..a213ef2 100644 --- a/users/index.js +++ b/users/index.js @@ -2,15 +2,16 @@ const express = require('express'); const mongoose = require('mongoose'); const bodyParser = require('body-parser'); +const dotenv = require('dotenv'); +dotenv.config(); // app and port definition const app = express(); const port = process.env.PORT || 8003; - // Connect to MongoDB -const mongoUri = process.env.MONGODB_URI || 'mongodb+srv://prueba:prueba@cluster0.kjzbhst.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0'; +const mongoUri = process.env.MONGODB_URI; mongoose.connect(mongoUri).then( console.log('Succesfully connected to MongoDB') diff --git a/users/package-lock.json b/users/package-lock.json index 69a6d4a..7aa0e79 100644 --- a/users/package-lock.json +++ b/users/package-lock.json @@ -13,6 +13,7 @@ "bcrypt": "^5.1.1", "body-parser": "^1.20.2", "cors": "^2.8.5", + "dotenv": "^16.4.5", "express": "^4.18.2", "jsonwebtoken": "^9.0.2", "mongodb": "^6.3.0", @@ -2089,6 +2090,17 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/ecdsa-sig-formatter": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", diff --git a/users/package.json b/users/package.json index 4e9ad1c..c66c9ac 100644 --- a/users/package.json +++ b/users/package.json @@ -22,6 +22,7 @@ "bcrypt": "^5.1.1", "body-parser": "^1.20.2", "cors": "^2.8.5", + "dotenv": "^16.4.5", "express": "^4.18.2", "jsonwebtoken": "^9.0.2", "mongodb": "^6.3.0",