2024-07-27 07:31:04 +00:00
|
|
|
package lib
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/ilyakaznacheev/cleanenv"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
2024-08-16 11:05:29 +00:00
|
|
|
Env string `env:"ENV" env-default:"prod"`
|
|
|
|
Pandoc string `env:"PANDOC" required:"true"`
|
2024-07-27 07:31:04 +00:00
|
|
|
PostgresDSN string `env:"POSTGRES_DSN" required:"true"`
|
2024-08-16 11:05:29 +00:00
|
|
|
JWTSecret string `env:"JWT_SECRET" required:"true"`
|
2024-07-27 07:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func MustSetupConfig() *Config {
|
|
|
|
var cfg Config
|
|
|
|
err := cleanenv.ReadConfig(".env", &cfg)
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("error reading config: %s", err.Error()))
|
|
|
|
}
|
|
|
|
return &cfg
|
|
|
|
}
|