From e0813ba69cc8601c0131591b98e33b09f9bd85c4 Mon Sep 17 00:00:00 2001 From: unurled Date: Wed, 23 Feb 2022 11:34:30 +0100 Subject: [PATCH] Add mongodb to dotenv --- .env.example | 3 ++- src/config/db.config.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index eaa684c..eee7df6 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ URL="http://localhost" -SERVER_PORT="3030" \ No newline at end of file +SERVER_PORT="3030" +MONGO="mongodb://127.0.0.1:27017/urlshortener" \ No newline at end of file diff --git a/src/config/db.config.js b/src/config/db.config.js index d84f96d..3b8f31c 100644 --- a/src/config/db.config.js +++ b/src/config/db.config.js @@ -1,8 +1,9 @@ +require('dotenv').config() // import mongoose package const mongoose = require('mongoose') // declare a Database string URI -const DB_URI = 'mongodb://127.0.0.1:27017/urlshortener' +const DB_URI = process.env.MONGO // establishing a database connection mongoose.connect(DB_URI)