Full refactor of codebase

This commit is contained in:
Jonas Hahn
2025-09-18 16:51:57 +02:00
parent 0e6e48cd7b
commit 4168e92601
34 changed files with 1176 additions and 1062 deletions

45
src/config/config.go Normal file
View File

@@ -0,0 +1,45 @@
package config
import (
"log"
"os"
"strconv"
"github.com/joho/godotenv"
)
var Config = struct {
BaseUrl string
Debug bool
CookieDomain string
AppPort int
}{
BaseUrl: "http://localhost:18765", // Default configurations
AppPort: 18765,
}
func init() {
var err error
// Load the environment
err = godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
// Set debug config
Config.Debug = os.Getenv("DEBUG") == "True"
// Get the listening port
port, _ := strconv.Atoi(os.Getenv("APP_PORT"))
if err != nil && port > 0 {
Config.AppPort = port
}
// Set the base URL
baseURL := os.Getenv("APP_BASE_URL")
if baseURL != "" {
print("okay")
Config.BaseUrl = baseURL
}
}