41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
// Config holds the application configuration
|
|
type Config struct {
|
|
Port string
|
|
DatabaseURL string
|
|
RedisURL string
|
|
JWTSecret string
|
|
OIDCIssuer string
|
|
OIDCClientID string
|
|
OIDCClientSecret string
|
|
Audience string
|
|
Issuer string
|
|
}
|
|
|
|
// LoadConfig loads the application configuration from environment variables
|
|
func LoadConfig() *Config {
|
|
return &Config{
|
|
Port: getEnv("PORT", "17000"),
|
|
DatabaseURL: getEnv("DATABASE_URL", "postgresql://mohportal:password@localhost:5432/mohportal"),
|
|
RedisURL: getEnv("REDIS_URL", "localhost:6379"),
|
|
JWTSecret: getEnv("JWT_SECRET", "supersecretkeyforjwt"),
|
|
OIDCIssuer: getEnv("OIDC_ISSUER", "http://localhost:8080/realms/master"),
|
|
OIDCClientID: getEnv("OIDC_CLIENT_ID", "mohportal-client"),
|
|
OIDCClientSecret: getEnv("OIDC_CLIENT_SECRET", "mohportal-secret"),
|
|
Audience: getEnv("AUDIENCE", "mohportal-api"),
|
|
Issuer: getEnv("ISSUER", "mohportal"),
|
|
}
|
|
}
|
|
|
|
// getEnv gets an environment variable or returns a default value
|
|
func getEnv(key, defaultValue string) string {
|
|
if value := os.Getenv(key); value != "" {
|
|
return value
|
|
}
|
|
return defaultValue
|
|
} |