Complete CRUD operations for habits

Implement all missing endpoints for full habit management:
- GET /api/v1/habits - List all user habits
- GET /api/v1/habits/{id} - Get specific habit
- PUT /api/v1/habits/{id} - Update habit
- DELETE /api/v1/habits/{id} - Archive habit (soft delete)
- GET /api/v1/habits/{id}/entries - Get habit entry history
- DELETE /api/v1/habits/{id}/entries/{date} - Unmark habit (soft delete entry)

All endpoints include:
- TDD approach with comprehensive test coverage
- JWT authentication and ownership validation
- Proper error handling (404, 403, 400, 500)
- Clean architecture with separated commands/queries
This commit is contained in:
2025-11-26 14:50:11 +01:00
parent e87b7df979
commit 74cd2ec84d
16 changed files with 1474 additions and 7 deletions
+6
View File
@@ -35,8 +35,14 @@ func NewRouter(corsOrigins string, habitHandlers *HabitHandlers, authHandlers *A
r.Route("/api/v1/habits", func(r chi.Router) {
r.Use(AuthMiddleware(jwtService))
r.Post("/", habitHandlers.CreateHabit)
r.Get("/", habitHandlers.GetUserHabits)
r.Get("/today", habitHandlers.GetTodaysHabits)
r.Get("/{id}", habitHandlers.GetHabitByID)
r.Put("/{id}", habitHandlers.UpdateHabit)
r.Delete("/{id}", habitHandlers.ArchiveHabit)
r.Get("/{id}/entries", habitHandlers.GetHabitEntries)
r.Post("/{id}/mark", habitHandlers.MarkHabit)
r.Delete("/{id}/entries/{date}", habitHandlers.UnmarkHabit)
})
return r