Major changes: - Migrate all handlers from Gin to Echo framework - Add new apperrors, echohelpers, and validator packages - Update middleware for Echo compatibility - Add ArchivedHandler to task categorization chain (archived tasks go to cancelled_tasks column) - Add 6 new integration tests: - RecurringTaskLifecycle: NextDueDate advancement for weekly/monthly tasks - MultiUserSharing: Complex sharing with user removal - TaskStateTransitions: All state transitions and kanban column changes - DateBoundaryEdgeCases: Threshold boundary testing - CascadeOperations: Residence deletion cascade effects - MultiUserOperations: Shared residence collaboration - Add single-purpose repository functions for kanban columns (GetOverdueTasks, GetDueSoonTasks, etc.) - Fix RemoveUser route param mismatch (userId -> user_id) - Fix determineExpectedColumn helper to correctly prioritize in_progress over overdue 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
46 lines
972 B
Go
46 lines
972 B
Go
package echohelpers
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
// DefaultQuery returns query param with default if not present
|
|
func DefaultQuery(c echo.Context, key, defaultValue string) string {
|
|
val := c.QueryParam(key)
|
|
if val == "" {
|
|
return defaultValue
|
|
}
|
|
return val
|
|
}
|
|
|
|
// ParseUintParam parses a path parameter as uint
|
|
func ParseUintParam(c echo.Context, name string) (uint, error) {
|
|
val, err := strconv.ParseUint(c.Param(name), 10, 32)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return uint(val), nil
|
|
}
|
|
|
|
// ParseIntParam parses a path parameter as int
|
|
func ParseIntParam(c echo.Context, name string) (int, error) {
|
|
val, err := strconv.Atoi(c.Param(name))
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return val, nil
|
|
}
|
|
|
|
// BindAndValidate binds and validates the request body
|
|
func BindAndValidate(c echo.Context, req interface{}) error {
|
|
if err := c.Bind(req); err != nil {
|
|
return err
|
|
}
|
|
if err := c.Validate(req); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|