Boost Azure Demo
This commit is contained in:
50
Backend/internal/config/config.go
Normal file
50
Backend/internal/config/config.go
Normal file
@@ -0,0 +1,50 @@
|
||||
// Path: Backend/internal/config/config.go
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Port string
|
||||
Environment string
|
||||
AllowedOrigins string
|
||||
DatabaseURL string
|
||||
JWTSecret string
|
||||
SessionCookie string
|
||||
AIReviewEndpoint string
|
||||
AIReviewAPIKey string
|
||||
AIReviewModel string
|
||||
}
|
||||
|
||||
func Load() *Config {
|
||||
return &Config{
|
||||
Port: getEnv("BACKEND_INTERNAL_PORT", "8081"),
|
||||
Environment: getEnv("GO_ENV", "development"),
|
||||
AllowedOrigins: getEnv("ALLOWED_ORIGINS", "http://localhost:3000,http://localhost:4321,http://localhost:8080,http://windows-wsl:8080"),
|
||||
DatabaseURL: getEnv("DATABASE_URL", "postgres://boostai:boostai_dev_password@localhost:5439/boostai?sslmode=disable"),
|
||||
JWTSecret: getEnv("JWT_SECRET", "boostai-dev-jwt-secret-change-me"),
|
||||
SessionCookie: getEnv("SESSION_COOKIE_NAME", "boostai_session"),
|
||||
AIReviewEndpoint: getEnv("AI_REVIEW_ENDPOINT", ""),
|
||||
AIReviewAPIKey: getEnv("AI_REVIEW_API_KEY", ""),
|
||||
AIReviewModel: getEnv("AI_REVIEW_MODEL", ""),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Config) IsDevelopment() bool {
|
||||
return strings.ToLower(c.Environment) == "development"
|
||||
}
|
||||
|
||||
func (c *Config) IsProduction() bool {
|
||||
return strings.ToLower(c.Environment) == "production"
|
||||
}
|
||||
|
||||
func getEnv(key, fallback string) string {
|
||||
if value, exists := os.LookupEnv(key); exists {
|
||||
return value
|
||||
}
|
||||
|
||||
return fallback
|
||||
}
|
||||
Reference in New Issue
Block a user