feat: basic firmware registry

This commit is contained in:
2025-10-21 14:27:21 +02:00
commit 986745d8c8
20 changed files with 1831 additions and 0 deletions

47
internal/config/config.go Normal file
View File

@@ -0,0 +1,47 @@
package config
import (
"os"
"strconv"
)
// Config holds the application configuration
type Config struct {
Port string
DBPath string
Registry string
MaxSize int64
}
// LoadConfig loads configuration from environment variables with defaults
func LoadConfig() *Config {
port := os.Getenv("PORT")
if port == "" {
port = "3002"
}
dbPath := os.Getenv("DB_PATH")
if dbPath == "" {
dbPath = "./registry.db"
}
registry := os.Getenv("REGISTRY_PATH")
if registry == "" {
registry = "registry"
}
maxSizeStr := os.Getenv("MAX_UPLOAD_SIZE")
maxSize := int64(32 << 20) // 32MB default
if maxSizeStr != "" {
if parsed, err := strconv.ParseInt(maxSizeStr, 10, 64); err == nil {
maxSize = parsed
}
}
return &Config{
Port: port,
DBPath: dbPath,
Registry: registry,
MaxSize: maxSize,
}
}