feat: rename db.connectionUri to mongodb.uri and bind MONGODB_URI env var
continuous-integration/drone/push Build is passing Details

main
RaviAnand Mohabir 1 year ago
parent 2f0c85eb6f
commit 686d2ee2a5

@ -38,7 +38,7 @@ func NewApp() *App {
store := sessions.NewCookieStore([]byte(viper.GetString("server.sessionkey"))) store := sessions.NewCookieStore([]byte(viper.GetString("server.sessionkey")))
serverAPI := options.ServerAPI(options.ServerAPIVersion1) 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 // Create a new client and connect to the server
client, err := mongo.Connect(context.TODO(), opts) client, err := mongo.Connect(context.TODO(), opts)
if err != nil { if err != nil {

@ -17,5 +17,7 @@ func main() {
viper.SetDefault("server.scheme", "http") viper.SetDefault("server.scheme", "http")
viper.SetDefault("server.host", "localhost:5001") viper.SetDefault("server.host", "localhost:5001")
viper.BindEnv("mongodb.uri", "MONGODB_URI")
cmd.Execute() cmd.Execute()
} }

Loading…
Cancel
Save