go-cook/internal/services/env.go

31 lines
619 B
Go
Raw Normal View History

2024-03-31 17:46:20 -07:00
package services
import (
"log"
"os"
"strconv"
"git.jamestombleson.com/jtom38/go-cook/internal/domain"
2024-03-31 17:46:20 -07:00
"github.com/joho/godotenv"
)
func NewEnvConfig() domain.EnvConfig {
err := godotenv.Load()
if err != nil {
log.Println(err)
}
disableMigrations, err := strconv.ParseBool(os.Getenv("DisableMigrationsOnStartup"))
if err != nil {
disableMigrations = false
}
2024-03-31 17:46:20 -07:00
return domain.EnvConfig{
AdminToken: os.Getenv("AdminToken"),
JwtSecret: os.Getenv("JwtSecret"),
ApiUri: os.Getenv("ApiUri"),
DisableMigrationsOnStartUp: disableMigrations,
2024-03-31 17:46:20 -07:00
}
}