26 lines
666 B
Go
26 lines
666 B
Go
package config
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/aykhans/oh-my-chat/internal/core/utils"
|
|
)
|
|
|
|
type AppConfig struct {
|
|
IsDev bool
|
|
CORSAllowedOrigins string
|
|
ListenerPort int
|
|
SecretKey string
|
|
JWTDuration *time.Duration
|
|
}
|
|
|
|
func NewAppConfig() *AppConfig {
|
|
return &AppConfig{
|
|
IsDev: utils.GetEnvOrDefault("APP_IS_PROD", "true") == "true",
|
|
CORSAllowedOrigins: utils.GetEnvOrDefault("APP_CORS_ALLOWED_ORIGINS", "*"),
|
|
ListenerPort: Str2IntOrDie(GetEnvOrDie("APP_LISTENER_PORT")),
|
|
SecretKey: GetEnvOrDie("APP_SECRET_KEY"),
|
|
JWTDuration: Str2DurationOrDie(GetEnvOrDie("APP_JWT_DURATION")),
|
|
}
|
|
}
|