feat: extend equipment and workout models with service tracking
This commit is contained in:
@@ -10,10 +10,15 @@ import (
|
||||
"github.com/go-chi/cors"
|
||||
"github.com/joho/godotenv"
|
||||
|
||||
"rideaware/internal/activity"
|
||||
"rideaware/internal/auth"
|
||||
"rideaware/internal/config"
|
||||
"rideaware/internal/equipment"
|
||||
"rideaware/internal/export"
|
||||
"rideaware/internal/integration"
|
||||
"rideaware/internal/middleware"
|
||||
"rideaware/internal/stats"
|
||||
"rideaware/internal/templates"
|
||||
"rideaware/internal/user"
|
||||
"rideaware/internal/workout"
|
||||
"rideaware/pkg/database"
|
||||
@@ -34,6 +39,8 @@ func main() {
|
||||
&user.Session{},
|
||||
&equipment.Equipment{},
|
||||
&workout.Workout{},
|
||||
&integration.OAuthConnection{},
|
||||
&integration.OAuthState{},
|
||||
); err != nil {
|
||||
log.Fatalf("Failed to migrate database: %v", err)
|
||||
}
|
||||
@@ -41,6 +48,9 @@ func main() {
|
||||
// Initialize JWT config
|
||||
config.InitJWT()
|
||||
|
||||
// Initialize OAuth config
|
||||
config.InitOAuth()
|
||||
|
||||
r := chi.NewRouter()
|
||||
|
||||
// Logging middleware
|
||||
@@ -107,6 +117,12 @@ func setupRoutes(r *chi.Mux) {
|
||||
r.Post("/api/password-reset/confirm", authHandler.ConfirmPasswordReset)
|
||||
r.Post("/api/refresh-token", authHandler.RefreshToken)
|
||||
|
||||
// OAuth callbacks (public - called by provider redirects)
|
||||
garminHandler := integration.NewGarminHandler()
|
||||
wahooHandler := integration.NewWahooHandler()
|
||||
r.Get("/api/garmin/callback", garminHandler.Callback)
|
||||
r.Get("/api/wahoo/callback", wahooHandler.Callback)
|
||||
|
||||
// Protected routes
|
||||
authMiddleware := middleware.NewAuthMiddleware()
|
||||
r.Route("/api/protected", func(r chi.Router) {
|
||||
@@ -124,6 +140,10 @@ func setupRoutes(r *chi.Mux) {
|
||||
r.Put("/equipment", equipmentHandler.UpdateEquipment)
|
||||
r.Delete("/equipment", equipmentHandler.DeleteEquipment)
|
||||
|
||||
// Equipment service tracking
|
||||
r.Post("/equipment/service", equipmentHandler.RecordService)
|
||||
r.Get("/equipment/service-status", equipmentHandler.GetServiceStatus)
|
||||
|
||||
// Training zones
|
||||
r.Get("/zones", equipmentHandler.GetTrainingZones)
|
||||
|
||||
@@ -132,10 +152,45 @@ func setupRoutes(r *chi.Mux) {
|
||||
r.Post("/workouts", workoutHandler.CreateWorkout)
|
||||
r.Get("/workouts", workoutHandler.GetWorkouts)
|
||||
r.Get("/workouts/month", workoutHandler.GetWorkoutsByMonth)
|
||||
r.Get("/workouts/equipment-stats", workoutHandler.GetEquipmentStats)
|
||||
r.Put("/workouts", workoutHandler.UpdateWorkout)
|
||||
r.Delete("/workouts", workoutHandler.DeleteWorkout)
|
||||
r.Get("/workout-types", workoutHandler.GetWorkoutTypes)
|
||||
r.Post("/workouts/upload", workoutHandler.UploadWorkoutFile)
|
||||
|
||||
// Activity import (FIT/TCX/GPX)
|
||||
activityHandler := activity.NewHandler()
|
||||
r.Post("/workouts/import", activityHandler.ImportActivity)
|
||||
|
||||
// Workout export routes
|
||||
exportHandler := export.NewHandler()
|
||||
r.Get("/workouts/export/fit", exportHandler.ExportFIT)
|
||||
r.Get("/workouts/export/zwo", exportHandler.ExportZWO)
|
||||
|
||||
// Garmin integration routes
|
||||
r.Get("/garmin/auth", garminHandler.StartAuth)
|
||||
r.Post("/workouts/push/garmin", garminHandler.PushWorkout)
|
||||
r.Get("/garmin/status", garminHandler.ConnectionStatus)
|
||||
r.Delete("/garmin/disconnect", garminHandler.Disconnect)
|
||||
|
||||
// Wahoo integration routes
|
||||
r.Get("/wahoo/auth", wahooHandler.StartAuth)
|
||||
r.Post("/workouts/push/wahoo", wahooHandler.PushWorkout)
|
||||
r.Get("/wahoo/status", wahooHandler.ConnectionStatus)
|
||||
r.Delete("/wahoo/disconnect", wahooHandler.Disconnect)
|
||||
|
||||
// Stats routes
|
||||
statsHandler := stats.NewHandler()
|
||||
r.Get("/stats/summary", statsHandler.GetSummary)
|
||||
r.Get("/stats/weekly", statsHandler.GetWeeklyStats)
|
||||
r.Get("/stats/monthly", statsHandler.GetMonthlyStats)
|
||||
r.Get("/stats/personal-bests", statsHandler.GetPersonalBests)
|
||||
|
||||
// Workout template routes
|
||||
templateHandler := templates.NewHandler()
|
||||
r.Get("/workout-templates", templateHandler.ListTemplates)
|
||||
r.Get("/workout-templates/detail", templateHandler.GetTemplate)
|
||||
r.Post("/workouts/from-template", templateHandler.CreateFromTemplate)
|
||||
})
|
||||
|
||||
log.Println("✅ Routes registered successfully")
|
||||
|
||||
Reference in New Issue
Block a user