Initial commit including .env
This commit is contained in:
50
config/config.go
Normal file
50
config/config.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Env string
|
||||
Port string
|
||||
DBName string
|
||||
DBUser string
|
||||
DBPassword string
|
||||
DBPort string
|
||||
DBHost string
|
||||
RedisHost string
|
||||
RedisPort string
|
||||
RedisUser string
|
||||
RedisPassword string
|
||||
JWTSecret string
|
||||
NatsURL string
|
||||
NatsUser string
|
||||
NatsPassword string
|
||||
}
|
||||
|
||||
func Load() *Config {
|
||||
return &Config{
|
||||
Env: getEnv("ENV", "development"),
|
||||
Port: getEnv("APP_PORT", "8081"),
|
||||
DBName: getEnv("DB_NAME", "logistics"),
|
||||
DBUser: getEnv("DB_USER", "admin"),
|
||||
DBPassword: getEnv("DB_PASSWORD", "Package@321#"),
|
||||
DBPort: getEnv("DB_PORT", "5433"),
|
||||
DBHost: getEnv("DB_HOST", "127.0.0.1"),
|
||||
RedisHost: getEnv("REDIS_HOST", "127.0.0.1"),
|
||||
RedisPort: getEnv("REDIS_PORT", "6379"),
|
||||
RedisUser: getEnv("REDIS_USER", ""),
|
||||
RedisPassword: getEnv("REDIS_PASSWORD", ""),
|
||||
JWTSecret: getEnv("JWT_SECRET_KEY", "DoormileSuperSecretJWTKey2026!"),
|
||||
NatsURL: getEnv("NATS_URL", "nats://66.116.226.161:4223"),
|
||||
NatsUser: getEnv("NATS_USER", "doormile"),
|
||||
NatsPassword: getEnv("NATS_PASSWORD", "Package@321#"),
|
||||
}
|
||||
}
|
||||
|
||||
func getEnv(key, fallback string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
Reference in New Issue
Block a user