| 1234567891011121314151617181920212223242526272829303132333435363738 |
- package config
- import (
- "os"
- )
- // Config holds the application configuration
- type Config struct {
- DBHost string
- DBPort string
- DBUser string
- DBPassword string
- DBName string
- JWTSecret string
- ServerPort string
- GinMode string
- }
- // Load reads configuration from environment variables with fallbacks
- func Load() *Config {
- return &Config{
- DBHost: getEnv("DB_HOST", "localhost"),
- DBPort: getEnv("DB_PORT", "5432"),
- DBUser: getEnv("DB_USER", "celestia"),
- DBPassword: getEnv("DB_PASSWORD", "celestia_secret"),
- DBName: getEnv("DB_NAME", "celestia_trace"),
- JWTSecret: getEnv("JWT_SECRET", "change-me-in-production"),
- ServerPort: getEnv("SERVER_PORT", "8080"),
- GinMode: getEnv("GIN_MODE", "release"),
- }
- }
- func getEnv(key, fallback string) string {
- if value, exists := os.LookupEnv(key); exists {
- return value
- }
- return fallback
- }
|