File tree Expand file tree Collapse file tree 5 files changed +5
-26
lines changed Expand file tree Collapse file tree 5 files changed +5
-26
lines changed Original file line number Diff line number Diff line change 2
2
# Copy this file to .env and replace the placeholder values with your own.
3
3
4
4
# Question Service
5
- QUESTION_DB_CLOUD_URI = <FILL-THIS-IN>
6
- QUESTION_DB_LOCAL_URI = mongodb://question-db:27017/question
5
+ QUESTION_DB_URI = <fill-this-in>
7
6
QUESTION_DB_USERNAME = user
8
- QUESTION_DB_PASSWORD = password
7
+ QUESTION_DB_PASSWORD = <fill-this-in>
9
8
10
9
# User Service
11
10
USER_SERVICE_CLOUD_URI = mongodb+srv://admin:<db_password>@cluster0.uo0vu.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0
Original file line number Diff line number Diff line change @@ -10,10 +10,6 @@ services:
10
10
- /app/node_modules
11
11
- ./services/question:/app
12
12
13
- question-db :
14
- ports :
15
- - 27017:27017
16
-
17
13
user :
18
14
command : npm run dev
19
15
volumes :
Original file line number Diff line number Diff line change @@ -18,28 +18,13 @@ services:
18
18
ports :
19
19
- 8081:8081
20
20
environment :
21
- DB_CLOUD_URI : ${QUESTION_DB_CLOUD_URI}
22
- DB_LOCAL_URI : ${QUESTION_DB_LOCAL_URI}
21
+ DB_URI : ${QUESTION_DB_URI}
23
22
DB_USERNAME : ${QUESTION_DB_USERNAME}
24
23
DB_PASSWORD : ${QUESTION_DB_PASSWORD}
25
24
networks :
26
25
- question-db-network
27
26
restart : always
28
27
29
- question-db :
30
- container_name : question-db
31
- image : mongo:7.0.14
32
- environment :
33
- MONGO_INITDB_ROOT_USERNAME : ${QUESTION_DB_USERNAME}
34
- MONGO_INITDB_ROOT_PASSWORD : ${QUESTION_DB_PASSWORD}
35
- volumes :
36
- - question-db:/data/db
37
- - ./services/question/init-mongo/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js
38
- networks :
39
- - question-db-network
40
- command : --quiet
41
- restart : always
42
-
43
28
user :
44
29
container_name : user
45
30
image : user
Original file line number Diff line number Diff line change 1
1
# This is a sample environment configuration file.
2
2
# Copy this file to .env and replace the placeholder values with your own.
3
- DB_CLOUD_URI = <FILL-THIS-IN>
4
- DB_LOCAL_URI = mongodb://question-db:27017/question
3
+ DB_URI = <FILL-THIS-IN>
5
4
DB_USERNAME = user
6
5
DB_PASSWORD = password
7
6
CORS_ORIGIN = *
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import mongoose from 'mongoose';
2
2
import { IQuestion , Question } from './questionModel' ;
3
3
4
4
export async function connectToDB ( ) {
5
- const mongoURI = process . env . NODE_ENV === 'production' ? process . env . DB_CLOUD_URI : process . env . DB_LOCAL_URI ;
5
+ const mongoURI = process . env . DB_URI ;
6
6
7
7
console . log ( 'MongoDB URI:' , mongoURI ) ;
8
8
You can’t perform that action at this time.
0 commit comments