package api import ( "database/sql" "github.com/go-chi/chi/v5" "atmoquest/features/auth" "atmoquest/internal/apitoken" "atmoquest/internal/connection" "atmoquest/internal/push" ) // SetupRoutes registers the /api/v1/ routes. // // All endpoints return JSON. Authentication is via session cookie (web) or // Bearer token (mobile). func SetupRoutes(router chi.Router, conn *sql.DB, authH *auth.Handlers, connQueue *connection.Queue, tokens *apitoken.Generator, pusher *push.Sender) { h := NewHandlers(conn, authH, connQueue, tokens, pusher) router.Route("/api/v1", func(r chi.Router) { r.Use(JSONMiddleware) // Auth r.Get("/auth/session", h.GetSession) r.Post("/oauth/login", h.OAuthLogin) r.Get("/oauth/callback", h.OAuthCallback) r.Post("/oauth/logout", h.Logout) // Profile r.Get("/profile", h.GetProfile) r.Put("/profile", h.UpdateProfile) r.Get("/users/{did}", h.GetUser) // Connections r.Get("/connections", h.ListConnections) r.Post("/connections/{did}", h.CreateConnection) r.Post("/connections/flush", h.FlushConnections) r.Get("/connections/{did}/notes", h.GetConnectionNotes) r.Put("/connections/{did}/notes", h.SaveConnectionNotes) // Events r.Get("/events", h.ListEvents) r.Get("/events/{token}", h.GetEvent) r.Get("/events/{token}/stats", h.GetEventStats) r.Post("/events/{token}/checkin", h.Checkin) r.Post("/events/flush", h.FlushEvents) // Badges r.Get("/badges", h.ListBadges) r.Get("/badges/recent", h.RecentBadges) // Settings r.Get("/settings", h.GetSettings) r.Put("/settings/privacy", h.UpdatePrivacy) r.Get("/settings/notes", h.ListNotes) r.Delete("/settings/account", h.DeleteAccount) // Devices (push notifications) r.Post("/devices", h.RegisterDevice) r.Delete("/devices/{token}", h.UnregisterDevice) }) }