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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user