Initial commit — energy dashboard frontend (TimescaleDB + Vue/Chart.js)

This commit is contained in:
2026-04-18 11:14:12 +02:00
commit 9fa7d36610
28 changed files with 3243 additions and 0 deletions

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

@@ -0,0 +1,58 @@
package config
import (
"os"
"strconv"
)
type Config struct {
Server ServerConfig
Auth AuthConfig
DB DBConfig
}
type ServerConfig struct {
Port int
}
type AuthConfig struct {
Username string
Password string
Secret string
}
type DBConfig struct {
DSN string
}
func Load() *Config {
return &Config{
Server: ServerConfig{
Port: getEnvInt("ENERGY_PORT", 8080),
},
Auth: AuthConfig{
Username: getEnv("ENERGY_AUTH_USER", "admin"),
Password: getEnv("ENERGY_AUTH_PASSWORD", ""),
Secret: getEnv("ENERGY_AUTH_SECRET", "change-me-in-production"),
},
DB: DBConfig{
DSN: getEnv("ENERGY_DB_DSN", "postgres://energy:changeme@localhost:5433/energy"),
},
}
}
func getEnv(key, fallback string) string {
if v := os.Getenv(key); v != "" {
return v
}
return fallback
}
func getEnvInt(key string, fallback int) int {
if v := os.Getenv(key); v != "" {
if i, err := strconv.Atoi(v); err == nil {
return i
}
}
return fallback
}