From 388479c7937c2d29fcd36b911146b137604e082f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lucas?= Date: Sun, 2 Jun 2024 16:27:36 -0300 Subject: [PATCH] feat: add .env function, this is necessary for security --- .env.example | 1 + .gitignore | 3 ++- app/config/db.config.js | 2 +- package.json | 1 + server.js | 2 ++ 5 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..9be12a0 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +MONGO_URL="your mongodb uri" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 25c8fdb..8f5e467 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -package-lock.json \ No newline at end of file +package-lock.json +.env \ No newline at end of file diff --git a/app/config/db.config.js b/app/config/db.config.js index ae4e12a..e843b10 100644 --- a/app/config/db.config.js +++ b/app/config/db.config.js @@ -1,3 +1,3 @@ module.exports = { - url: "mongodb://0.0.0.0:27017/bezkoder_db" + url: process.env.MONGO_URL }; diff --git a/package.json b/package.json index 4d88561..42326e9 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "license": "ISC", "dependencies": { "cors": "^2.8.5", + "dotenv": "^16.4.5", "express": "^4.18.2", "mongoose": "^6.11.1" } diff --git a/server.js b/server.js index 314d1e5..1884535 100644 --- a/server.js +++ b/server.js @@ -1,3 +1,5 @@ +//import dotenv module, and call config function to be able to use .env +require('dotenv').config() const express = require("express"); const cors = require("cors");