diff --git a/Makefile b/Makefile index 64576f6..ce4a5f4 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ build: build-web build-server # Build the Go server build-server: - CGO_ENABLED=0 go build -o dumpster-server ./cmd/server + CGO_ENABLED=0 go build -ldflags "-X main.GitSHA=$(GIT_SHA)" -o dumpster-server ./cmd/server # Build the TUI client build-tui: diff --git a/cmd/server/main.go b/cmd/server/main.go index 733b092..1705eff 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -47,9 +47,8 @@ import ( // @host localhost:8080 // @BasePath /api/v1 // @schemes http https -// @securityDefinitions.apikey SessionAuth -// @in cookie -// @name dumpster_session +var GitSHA = "dev" + func main() { logger := slog.New(slog.NewTextHandler(os.Stdout, nil)) @@ -153,6 +152,14 @@ func main() { // API routes r.Route("/api/v1", func(r chi.Router) { + r.Get("/version", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") + json.NewEncoder(w).Encode(map[string]string{ + "version": GitSHA, + }) + }) + // Auth (public: register, login, logout) with strict rate limiting r.Route("/auth", func(r chi.Router) { r.Use(middleware.RateLimit(5, 10)) // 5 req/s, burst 10 diff --git a/web/src/components/Layout.tsx b/web/src/components/Layout.tsx index e9e7929..c32c73c 100644 --- a/web/src/components/Layout.tsx +++ b/web/src/components/Layout.tsx @@ -15,6 +15,7 @@ import { MemberList } from './MemberList.tsx'; import { VoicePanel } from './VoicePanel.tsx'; import { ServerSettingsModal } from './ServerSettingsModal.tsx'; import { ThemeToggle } from './ThemeToggle.tsx'; +import { VersionNotifier } from './VersionNotifier.tsx'; const STATUS_CYCLE: UserStatus[] = ['online', 'idle', 'dnd', 'offline']; function statusColor(status: UserStatus): string { @@ -99,6 +100,7 @@ export function Layout() { return (