Skip to content

Commit

Permalink
Update configurations on MongoDB - changing URI
Browse files Browse the repository at this point in the history
  • Loading branch information
KhoonSun47 committed Oct 20, 2024
1 parent 59f9af3 commit 91e4dff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ services:
context: services/question
dockerfile: Dockerfile
environment:
DB_CLOUD_URI: ${QUESTION_DB_CLOUD_URI}
DB_LOCAL_URI: ${QUESTION_DB_LOCAL_URI}
QUESTION_DB_CLOUD_URI: ${QUESTION_DB_CLOUD_URI}
QUESTION_DB_LOCAL_URI: ${QUESTION_DB_LOCAL_URI}
DB_USERNAME: ${QUESTION_DB_USERNAME}
DB_PASSWORD: ${QUESTION_DB_PASSWORD}
networks:
Expand Down Expand Up @@ -88,8 +88,8 @@ services:
ports:
- 8084:8084
environment:
MONGO_URI: ${MONGO_URI}
MONGODB_URI: ${MONGODB_URI}
COLLAB_CLOUD_MONGO_URI: ${COLLAB_CLOUD_MONGO_URI}
COLLAB_LOCAL_MONGO_URI: ${COLLAB_LOCAL_MONGO_URI}
CORS_ORIGIN: ${CORS_ORIGIN}
networks:
- collaboration-db-network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export class QuestionBoxComponent implements OnInit {
setQuestion() {
this.questionService.getQuestionByID(this.questionId).subscribe({
next: response => {
this.question = response.data || [];
// @ts-ignore
this.question = response.data || [];
},
error: errorMessage => {
this.question = {} as Question;
Expand Down
2 changes: 1 addition & 1 deletion services/collaboration/src/services/mongodbService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MongoClient } from 'mongodb';
import { MongodbPersistence } from 'y-mongodb-provider';

const MONGO_URI = process.env.MONGO_URI || 'mongodb://localhost:27017/collaboration-service';
const MONGO_URI = process.env.COLLAB_CLOUD_MONGO_URI || 'mongodb://localhost:27017/collaboration-service';
const COLLECTION_NAME = 'yjs-documents';

/**
Expand Down
3 changes: 2 additions & 1 deletion services/question/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import mongoose from 'mongoose';
import { IQuestion, Question } from './questionModel';

export async function connectToDB() {
const mongoURI = process.env.NODE_ENV === 'production' ? process.env.DB_CLOUD_URI : process.env.DB_LOCAL_URI;
const mongoURI = process.env.QUESTION_DB_CLOUD_URI || "mongodb://localhost:27017/question-";

console.log('MongoDB URI:', mongoURI);
console.log(process.env.DB_USERNAME, process.env.DB_PASSWORD);

if (!mongoURI) {
throw new Error('MongoDB URI not specified');
Expand Down

0 comments on commit 91e4dff

Please sign in to comment.