First commit
This commit is contained in:
32
config/config.go
Normal file
32
config/config.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Port string
|
||||
MongoDBURI string
|
||||
DBName string
|
||||
JWTSecret string
|
||||
Environment string
|
||||
CertsPath string
|
||||
}
|
||||
|
||||
func LoadConfig() *Config {
|
||||
return &Config{
|
||||
Port: getEnv("PORT", "8080"),
|
||||
MongoDBURI: getEnv("MONGODB_URI", "mongodb://localhost:27017"),
|
||||
DBName: getEnv("DB_NAME", "pki_db"),
|
||||
JWTSecret: getEnv("JWT_SECRET", "your-secret-key"),
|
||||
Environment: getEnv("ENVIRONMENT", "development"),
|
||||
CertsPath: getEnv("CERTS_PATH", "./certs"),
|
||||
}
|
||||
}
|
||||
|
||||
func getEnv(key, defaultValue string) string {
|
||||
if value := os.Getenv(key); value != "" {
|
||||
return value
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
Reference in New Issue
Block a user