Migrate from Gin to Echo framework and add comprehensive integration tests

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>
This commit is contained in:
Trey t
2025-12-16 13:52:08 -06:00
parent c51f1ce34a
commit 6dac34e373
98 changed files with 8209 additions and 4425 deletions

View File

@@ -3,39 +3,41 @@ package i18n
import (
"strings"
"github.com/gin-gonic/gin"
"github.com/labstack/echo/v4"
"github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/text/language"
)
const (
// LocalizerKey is the key used to store the localizer in Gin context
// LocalizerKey is the key used to store the localizer in Echo context
LocalizerKey = "i18n_localizer"
// LocaleKey is the key used to store the detected locale in Gin context
// LocaleKey is the key used to store the detected locale in Echo context
LocaleKey = "i18n_locale"
)
// Middleware returns a Gin middleware that detects the user's preferred language
// Middleware returns an Echo middleware that detects the user's preferred language
// from the Accept-Language header and stores a localizer in the context
func Middleware() gin.HandlerFunc {
return func(c *gin.Context) {
// Get Accept-Language header
acceptLang := c.GetHeader("Accept-Language")
func Middleware() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
// Get Accept-Language header
acceptLang := c.Request().Header.Get("Accept-Language")
// Parse the preferred languages
langs := parseAcceptLanguage(acceptLang)
// Parse the preferred languages
langs := parseAcceptLanguage(acceptLang)
// Create localizer with the preferred languages
localizer := NewLocalizer(langs...)
// Create localizer with the preferred languages
localizer := NewLocalizer(langs...)
// Determine the best matched locale for storage
locale := matchLocale(langs)
// Determine the best matched locale for storage
locale := matchLocale(langs)
// Store in context
c.Set(LocalizerKey, localizer)
c.Set(LocaleKey, locale)
// Store in context
c.Set(LocalizerKey, localizer)
c.Set(LocaleKey, locale)
c.Next()
return next(c)
}
}
}
@@ -86,9 +88,10 @@ func matchLocale(langs []string) string {
return DefaultLanguage
}
// GetLocalizer retrieves the localizer from the Gin context
func GetLocalizer(c *gin.Context) *i18n.Localizer {
if localizer, exists := c.Get(LocalizerKey); exists {
// GetLocalizer retrieves the localizer from the Echo context
func GetLocalizer(c echo.Context) *i18n.Localizer {
localizer := c.Get(LocalizerKey)
if localizer != nil {
if l, ok := localizer.(*i18n.Localizer); ok {
return l
}
@@ -96,9 +99,10 @@ func GetLocalizer(c *gin.Context) *i18n.Localizer {
return NewLocalizer(DefaultLanguage)
}
// GetLocale retrieves the detected locale from the Gin context
func GetLocale(c *gin.Context) string {
if locale, exists := c.Get(LocaleKey); exists {
// GetLocale retrieves the detected locale from the Echo context
func GetLocale(c echo.Context) string {
locale := c.Get(LocaleKey)
if locale != nil {
if l, ok := locale.(string); ok {
return l
}
@@ -107,16 +111,16 @@ func GetLocale(c *gin.Context) string {
}
// LocalizedError returns a localized error message
func LocalizedError(c *gin.Context, messageID string, templateData map[string]interface{}) string {
func LocalizedError(c echo.Context, messageID string, templateData map[string]interface{}) string {
return T(GetLocalizer(c), messageID, templateData)
}
// LocalizedMessage returns a localized message
func LocalizedMessage(c *gin.Context, messageID string) string {
func LocalizedMessage(c echo.Context, messageID string) string {
return TSimple(GetLocalizer(c), messageID)
}
// LocalizedMessageWithData returns a localized message with template data
func LocalizedMessageWithData(c *gin.Context, messageID string, templateData map[string]interface{}) string {
func LocalizedMessageWithData(c echo.Context, messageID string, templateData map[string]interface{}) string {
return T(GetLocalizer(c), messageID, templateData)
}