go-cook/api/services/env.go

30 lines
563 B
Go

package services
import (
"log"
"os"
"strconv"
"git.jamestombleson.com/jtom38/go-cook/api/domain"
"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
}
return domain.EnvConfig{
AdminToken: os.Getenv("AdminToken"),
JwtSecret: os.Getenv("JwtSecret"),
DisableMigrationsOnStartUp: disableMigrations,
}
}