diff options
-rw-r--r-- | .env.example | 1 | ||||
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | index.js | 4 | ||||
-rw-r--r-- | package-lock.json | 5 | ||||
-rw-r--r-- | package.json | 1 |
6 files changed, 13 insertions, 1 deletions
diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..71a28fd --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +DB_CONN=mongodb://localhost/playground_db @@ -1 +1,2 @@ node_modules/ +.env @@ -1,3 +1,5 @@ # About this project I use this repository to play with Node.js. + +If you want to use this repository don't forget to copy `.env.example` to `.env` and modify it accordingly. @@ -1,10 +1,12 @@ const express = require('express'); const exphbs = require('express-handlebars'); const mongoose = require('mongoose'); +require('dotenv').config(); + const webRoutes = require('./routes/web'); const app = express(); -mongoose.connect('mongodb://localhost/playground_db', { +mongoose.connect(process.env.DB_CONN, { useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false diff --git a/package-lock.json b/package-lock.json index 3dfdef5..d03875b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -417,6 +417,11 @@ "is-obj": "^2.0.0" } }, + "dotenv": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-9.0.0.tgz", + "integrity": "sha512-yy3x9XjojW8ROTBePD25AcMoHqGHsvHmtfw8QWlpEXyMMXXPj6brUA464AptUvHuTPRmNz6Sd3ZLNLeJl6dHJA==" + }, "duplexer3": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", diff --git a/package.json b/package.json index b0422c5..751aead 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "author": "Mateja Maric", "license": "GPL-3.0", "dependencies": { + "dotenv": "^9.0.0", "express": "^4.17.1", "express-handlebars": "^5.3.0", "mongoose": "^5.12.7" |