diff --git a/backend-services/feed-service/app/models/MongoDBClient.scala b/backend-services/feed-service/app/models/MongoDBClient.scala index b7af45a7e15431daa011b86bbed4ad506d6bcc53..80583bb392da35a7be0d982134f29b2853a92b7e 100644 --- a/backend-services/feed-service/app/models/MongoDBClient.scala +++ b/backend-services/feed-service/app/models/MongoDBClient.scala @@ -1,5 +1,7 @@ package models +import com.typesafe.config.ConfigFactory + import org.mongodb.scala.{MongoClient, MongoDatabase, MongoCollection, Document, FindObservable, Observer, Observable} import org.mongodb.scala.model.{Filters, Projections, Sorts} import org.bson.conversions.Bson @@ -15,6 +17,9 @@ import scala.util.{Success, Failure, Try} * @constructor Creates a new instance of the MongoDBClient class. */ class MongoDBClient { + // Loads the default configuration + private val config = ConfigFactory.load() + // Connects to a MongoDB Client when class is constructed private var client: MongoClient = this.connect() @@ -24,7 +29,7 @@ class MongoDBClient { * @return A MongoClient instance. */ def connect(): MongoClient = { - MongoClient("mongodb://localhost:27017/") + MongoClient(config.getString("mongo.default.url")) } /** diff --git a/backend-services/feed-service/conf/application.conf b/backend-services/feed-service/conf/application.conf index cb94680e75b020e0e8c786bc63db4bd8e92634ba..4813168066f5b540753cf085860c08ff54404a50 100644 --- a/backend-services/feed-service/conf/application.conf +++ b/backend-services/feed-service/conf/application.conf @@ -1 +1,2 @@ -# https://www.playframework.com/documentation/latest/Configuration +# MongoDB Connection Strings +mongo.default.url="mongodb://localhost:27017/"