Cleanup dataclient pour cmd/api

Utiliser NewDataClientFromViper
This commit is contained in:
Victor Lacasse-Beaudoin 2023-06-02 16:16:18 -04:00
parent 412727bf9c
commit 883edccf87

View file

@ -27,14 +27,6 @@ var apiCmd = &cobra.Command{
apiKey = viper.GetString("api.key") apiKey = viper.GetString("api.key")
apiPort = viper.GetInt("api.port") apiPort = viper.GetInt("api.port")
connection := data.PostgresConnection{
User: viper.GetString("db.user"),
Password: viper.GetString("db.password"),
Host: viper.GetString("db.host"),
Database: viper.GetString("db.database"),
Port: viper.GetInt("db.port"),
}
e := echo.New() e := echo.New()
// Middlewares // Middlewares
@ -63,7 +55,7 @@ var apiCmd = &cobra.Command{
// Execution // Execution
client, err := data.NewDataClient(connection) client, err := data.NewDataClientFromViper()
if err != nil { if err != nil {
log.Fatalf("Could not establish database connection.\n Error: %s\n", err) log.Fatalf("Could not establish database connection.\n Error: %s\n", err)
} }