102 lines
2.2 KiB
Go
102 lines
2.2 KiB
Go
package config
|
|
|
|
import "strings"
|
|
|
|
type Config struct {
|
|
AppConf AppConfig
|
|
DBConf DatabaseConfig
|
|
JWTConf JWTConfig
|
|
GrpcConf GrpcConfig
|
|
MediaConf MediaConfig
|
|
ImageConf ImageStorageConfig
|
|
}
|
|
|
|
type AppConfig struct {
|
|
Host string
|
|
Port string
|
|
LogLvl string
|
|
ApiPrefix string
|
|
GinMode string
|
|
AllowedOrigins []string
|
|
}
|
|
|
|
type DatabaseConfig struct {
|
|
Host string
|
|
Port string
|
|
User string
|
|
Password string
|
|
SSLMode string
|
|
DBName string
|
|
LogLevel string
|
|
}
|
|
|
|
type JWTConfig struct {
|
|
Secret string
|
|
Issuer string
|
|
AccessExpire string
|
|
RefreshExpire string
|
|
}
|
|
|
|
type GrpcConfig struct {
|
|
GrpcServerPort string
|
|
GrpcClientPort string
|
|
}
|
|
|
|
type MediaConfig struct {
|
|
Endpoint string
|
|
User string
|
|
Password string
|
|
Secure string
|
|
}
|
|
|
|
type ImageStorageConfig struct {
|
|
Host string
|
|
Port string
|
|
}
|
|
|
|
func NewConfig() *Config {
|
|
return &Config{
|
|
AppConf: AppConfig{
|
|
Host: getEnv("APP_HOST", ""),
|
|
Port: getEnv("APP_PORT", ""),
|
|
LogLvl: getEnv("APP_LOGLVL", ""),
|
|
ApiPrefix: getEnv("APP_API_PREFIX", ""),
|
|
GinMode: getEnv("APP_GIN_MODE", ""),
|
|
AllowedOrigins: strings.Split(getEnv("APP_ALLOWED_ORIGINS", ""), ","),
|
|
},
|
|
|
|
DBConf: DatabaseConfig{
|
|
Host: getEnv("DB_HOST", ""),
|
|
Port: getEnv("DB_PORT", ""),
|
|
User: getEnv("DB_USER", ""),
|
|
Password: getEnv("DB_PASSWORD", ""),
|
|
SSLMode: getEnv("DB_SSLMODE", ""),
|
|
DBName: getEnv("DB_NAME", ""),
|
|
LogLevel: getEnv("DB_LOGLEVEL", ""),
|
|
},
|
|
|
|
JWTConf: JWTConfig{
|
|
Secret: getEnv("JWT_SECRET", ""),
|
|
Issuer: getEnv("JWT_ISSUER", ""),
|
|
AccessExpire: getEnv("JWT_ACCESS_EXPIRE", ""),
|
|
RefreshExpire: getEnv("JWT_REFRESH_EXPIRE", ""),
|
|
},
|
|
|
|
GrpcConf: GrpcConfig{
|
|
GrpcServerPort: getEnv("GRPC_SERVER_PORT", ""),
|
|
GrpcClientPort: getEnv("GRPC_CLIENT_PORT", ""),
|
|
},
|
|
|
|
MediaConf: MediaConfig{
|
|
Endpoint: getEnv("MEDIA_STORAGE_ENDPOINT", ""),
|
|
User: getEnv("MEDIA_STORAGE_USER", ""),
|
|
Password: getEnv("MEDIA_STORAGE_PASSWORD", ""),
|
|
Secure: getEnv("MEDIA_STORAGE_SECURE", ""),
|
|
},
|
|
|
|
ImageConf: ImageStorageConfig{
|
|
Host: getEnv("IMAGE_STORAGE_HOST", ""),
|
|
Port: getEnv("IMAGE_STORAGE_PORT", ""),
|
|
},
|
|
}
|
|
}
|