Add full shop application: Go backend, PostgreSQL, Docker, Caddy and admin panel.

This commit is contained in:
shop
2026-06-25 16:39:33 +03:00
parent a150e4f8c6
commit ee5688f722
24 changed files with 1797 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
package config
import (
"crypto/rand"
"encoding/hex"
"log"
"os"
)
type Config struct {
AdminEmail string
AdminPassword string
SessionSecret string
}
func Load() Config {
cfg := Config{
AdminEmail: os.Getenv("ADMIN_EMAIL"),
AdminPassword: os.Getenv("ADMIN_PASSWORD"),
SessionSecret: os.Getenv("SESSION_SECRET"),
}
if cfg.SessionSecret == "" {
cfg.SessionSecret = randomSecret()
log.Println("warning: SESSION_SECRET not set, using random value (sessions reset on restart)")
}
return cfg
}
func randomSecret() string {
b := make([]byte, 32)
if _, err := rand.Read(b); err != nil {
panic(err)
}
return hex.EncodeToString(b)
}