From 686d2ee2a5ba3d84e7e0089dcf971d3d1274216c Mon Sep 17 00:00:00 2001 From: RaviAnand Mohabir Date: Thu, 26 Oct 2023 20:49:43 +0200 Subject: [PATCH] feat: :sparkles: rename db.connectionUri to mongodb.uri and bind MONGODB_URI env var --- core/app.go | 2 +- main.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/app.go b/core/app.go index d84fd56..3c9bf25 100644 --- a/core/app.go +++ b/core/app.go @@ -38,7 +38,7 @@ func NewApp() *App { store := sessions.NewCookieStore([]byte(viper.GetString("server.sessionkey"))) serverAPI := options.ServerAPI(options.ServerAPIVersion1) - opts := options.Client().ApplyURI(viper.GetString("db.connectionuri")).SetServerAPIOptions(serverAPI) + opts := options.Client().ApplyURI(viper.GetString("mongodb.uri")).SetServerAPIOptions(serverAPI) // Create a new client and connect to the server client, err := mongo.Connect(context.TODO(), opts) if err != nil { diff --git a/main.go b/main.go index 31ab31e..39626f1 100644 --- a/main.go +++ b/main.go @@ -17,5 +17,7 @@ func main() { viper.SetDefault("server.scheme", "http") viper.SetDefault("server.host", "localhost:5001") + viper.BindEnv("mongodb.uri", "MONGODB_URI") + cmd.Execute() }