feat: add WannPassts booking app with Go backend and Vue frontend
Initial project setup for a privacy-focused, self-hosted scheduling app: - Go backend with JWT auth, SQLite storage, and chi router - Calendar integrations via Google OAuth (FreeBusy), CalDAV, and ICS links - Public booking pages with configurable slots and booking requests - AES-256-GCM encryption for stored provider tokens - Vue 3 + TypeScript frontend with Vite, Pinia, and Vue Router - Docs, .gitignore, and .env.example for local development
This commit is contained in:
commit
cb30223fd4
47 changed files with 6599 additions and 0 deletions
64
backend/internal/config/config.go
Normal file
64
backend/internal/config/config.go
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Port string
|
||||
DBPath string
|
||||
AppURL string
|
||||
FrontendURL string
|
||||
JWTSecret string
|
||||
EncryptionKey string
|
||||
GoogleClientID string
|
||||
GoogleClientSecret string
|
||||
StaticDir string
|
||||
}
|
||||
|
||||
// Load liest die Konfiguration aus Umgebungsvariablen (.env wird unterstützt).
|
||||
// Fehlende Secrets werden nur für die Entwicklung zufällig erzeugt.
|
||||
func Load() Config {
|
||||
_ = godotenv.Load()
|
||||
|
||||
cfg := Config{
|
||||
Port: env("PORT", "8080"),
|
||||
DBPath: env("DB_PATH", "wannpassts.db"),
|
||||
AppURL: env("APP_URL", "http://localhost:8080"),
|
||||
FrontendURL: env("FRONTEND_URL", "http://localhost:5173"),
|
||||
JWTSecret: os.Getenv("JWT_SECRET"),
|
||||
EncryptionKey: os.Getenv("ENCRYPTION_KEY"),
|
||||
GoogleClientID: os.Getenv("GOOGLE_CLIENT_ID"),
|
||||
GoogleClientSecret: os.Getenv("GOOGLE_CLIENT_SECRET"),
|
||||
StaticDir: env("STATIC_DIR", ""),
|
||||
}
|
||||
if cfg.JWTSecret == "" {
|
||||
cfg.JWTSecret = randomHex(32)
|
||||
log.Println("WARNUNG: JWT_SECRET nicht gesetzt – temporäres Secret erzeugt (Sessions verfallen bei Neustart).")
|
||||
}
|
||||
if cfg.EncryptionKey == "" {
|
||||
cfg.EncryptionKey = randomHex(32)
|
||||
log.Println("WARNUNG: ENCRYPTION_KEY nicht gesetzt – temporärer Schlüssel erzeugt (Kalender-Tokens verfallen bei Neustart).")
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
||||
func env(key, def string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
func randomHex(n int) string {
|
||||
b := make([]byte, n)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
log.Fatalf("Zufallszahl nicht verfügbar: %v", err)
|
||||
}
|
||||
return hex.EncodeToString(b)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue