version 1
Build and Deploy / test-backend (push) Successful in 1m11s
Build and Deploy / lint-frontend (push) Successful in 21s
Build and Deploy / build-backend (push) Successful in 58s
Build and Deploy / deploy (push) Canceled after 0s
Build and Deploy / build-frontend (push) Canceled after 5m38s
Build and Deploy / test-backend (push) Successful in 1m11s
Build and Deploy / lint-frontend (push) Successful in 21s
Build and Deploy / build-backend (push) Successful in 58s
Build and Deploy / deploy (push) Canceled after 0s
Build and Deploy / build-frontend (push) Canceled after 5m38s
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Port string
|
||||
|
||||
RedisConnectionString string
|
||||
PostgresConnectionString string
|
||||
|
||||
FrontendUrl string
|
||||
|
||||
DeepLAPIKey string
|
||||
OpenRouterAPIKey string
|
||||
GroqAPIKey string
|
||||
AIMonthlyTokenLimit int64
|
||||
KotosoftIDAPIUrl string
|
||||
SessionSecret string
|
||||
}
|
||||
|
||||
func Load() *Config {
|
||||
if err := godotenv.Load(); err != nil {
|
||||
log.Println("no .env file found, relying on system environment variables")
|
||||
}
|
||||
|
||||
return &Config{
|
||||
Port: getEnv("PORT", "8080"),
|
||||
RedisConnectionString: getEnv("REDIS_CONNECTION_STRING", ""),
|
||||
PostgresConnectionString: getEnv("POSTGRES_CONNECTION_STRING", ""),
|
||||
FrontendUrl: getEnv("FRONTEND_URL", "http://localhost:3000"),
|
||||
DeepLAPIKey: getEnv("DEEPL_API_KEY", ""),
|
||||
OpenRouterAPIKey: getEnv("OPENROUTER_API_KEY", ""),
|
||||
GroqAPIKey: getEnv("GROQ_API_KEY", ""),
|
||||
AIMonthlyTokenLimit: getEnvInt64("AI_MONTHLY_TOKEN_LIMIT", 200_000*30),
|
||||
KotosoftIDAPIUrl: getEnv("KOTOSOFT_ID_API_URL", ""),
|
||||
SessionSecret: getEnv("SESSION_SECRET", ""),
|
||||
}
|
||||
}
|
||||
|
||||
func getEnv(key, fallback string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
func getEnvInt64(key string, fallback int64) int64 {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
if n, err := strconv.ParseInt(v, 10, 64); err == nil {
|
||||
return n
|
||||
}
|
||||
log.Printf("invalid %s value %q, falling back to %d", key, v, fallback)
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
Reference in New Issue
Block a user