feat: add SQLite support, setup wizard enhancements, and live dashboard

Add zero-dependency SQLite mode so users can run Erupe without
PostgreSQL. A transparent db.DB wrapper auto-translates PostgreSQL
SQL ($N placeholders, now(), ::casts, ILIKE, public. prefix,
TRUNCATE) for SQLite at runtime — all 28 repo files use the wrapper
with no per-query changes needed.

Setup wizard gains two new steps: quest file detection with download
link, and gameplay presets (solo/small/community/rebalanced). The API
server gets a /dashboard endpoint with auto-refreshing stats.

CI release workflow now builds and pushes Docker images to GHCR
alongside binary artifacts on tag push.

Key changes:
- common/db: DB/Tx wrapper with 6 SQL translation rules
- server/migrations/sqlite: full SQLite schema (0001-0005)
- config: Database.Driver field ("postgres" or "sqlite")
- main.go: SQLite connection with WAL mode, single writer
- server/setup: quest check + preset selection steps
- server/api: /dashboard with live stats
- .github/workflows: Docker in release, deduplicate docker.yml
This commit is contained in:
Houmgaor
2026-03-05 18:00:30 +01:00
parent 03adb21e99
commit ecfe58ffb4
86 changed files with 2326 additions and 356 deletions

View File

@@ -9,6 +9,8 @@ import (
"sync"
"time"
dbutil "erupe-ce/common/db"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/jmoiron/sqlx"
@@ -33,6 +35,7 @@ type APIServer struct {
sessionRepo APISessionRepo
eventRepo APIEventRepo
httpServer *http.Server
startTime time.Time
isShuttingDown bool
}
@@ -45,19 +48,26 @@ func NewAPIServer(config *Config) *APIServer {
httpServer: &http.Server{},
}
if config.DB != nil {
s.userRepo = NewAPIUserRepository(config.DB)
s.charRepo = NewAPICharacterRepository(config.DB)
s.sessionRepo = NewAPISessionRepository(config.DB)
s.eventRepo = NewAPIEventRepository(config.DB)
wdb := dbutil.Wrap(config.DB)
s.userRepo = NewAPIUserRepository(wdb)
s.charRepo = NewAPICharacterRepository(wdb)
s.sessionRepo = NewAPISessionRepository(wdb)
s.eventRepo = NewAPIEventRepository(wdb)
}
return s
}
// Start starts the server in a new goroutine.
func (s *APIServer) Start() error {
s.startTime = time.Now()
// Set up the routes responsible for serving the launcher HTML, serverlist, unique name check, and JP auth.
r := mux.NewRouter()
// Dashboard routes (before catch-all)
r.HandleFunc("/dashboard", s.Dashboard)
r.HandleFunc("/api/dashboard/stats", s.DashboardStatsJSON).Methods("GET")
// Legacy routes (unchanged, no method enforcement)
r.HandleFunc("/launcher", s.Launcher)
r.HandleFunc("/login", s.Login)