refactor: migrate DI to Wire, replace startup registries with on-demand DB queries
- Add google/wire; generate wire_gen.go from wire.go injector - Move all constructor wiring out of main.go into providers.go / wire.go - Export recognition.IngredientRepository (was unexported, blocked Wire binding) - Delete units/cuisine/tag registry.go files (global state + unused NameFor helpers) - Replace List handlers with NewListHandler(pool) using COALESCE SQL queries - Remove units/cuisine/tag LoadFromDB from server startup; locale.LoadFromDB kept (locale.Supported is used by language middleware on every request) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/food-ai/backend/internal/auth"
|
||||
"github.com/food-ai/backend/internal/cuisine"
|
||||
"github.com/food-ai/backend/internal/diary"
|
||||
"github.com/food-ai/backend/internal/dish"
|
||||
"github.com/food-ai/backend/internal/home"
|
||||
@@ -14,8 +13,6 @@ import (
|
||||
"github.com/food-ai/backend/internal/menu"
|
||||
"github.com/food-ai/backend/internal/middleware"
|
||||
"github.com/food-ai/backend/internal/recipe"
|
||||
"github.com/food-ai/backend/internal/tag"
|
||||
"github.com/food-ai/backend/internal/units"
|
||||
"github.com/food-ai/backend/internal/product"
|
||||
"github.com/food-ai/backend/internal/recognition"
|
||||
"github.com/food-ai/backend/internal/recommendation"
|
||||
@@ -41,6 +38,9 @@ func NewRouter(
|
||||
recipeHandler *recipe.Handler,
|
||||
authMiddleware func(http.Handler) http.Handler,
|
||||
allowedOrigins []string,
|
||||
unitsListHandler http.HandlerFunc,
|
||||
cuisineListHandler http.HandlerFunc,
|
||||
tagListHandler http.HandlerFunc,
|
||||
) *chi.Mux {
|
||||
r := chi.NewRouter()
|
||||
|
||||
@@ -54,9 +54,9 @@ func NewRouter(
|
||||
// Public
|
||||
r.Get("/health", healthCheck(pool))
|
||||
r.Get("/languages", language.List)
|
||||
r.Get("/units", units.List)
|
||||
r.Get("/cuisines", cuisine.List)
|
||||
r.Get("/tags", tag.List)
|
||||
r.Get("/units", unitsListHandler)
|
||||
r.Get("/cuisines", cuisineListHandler)
|
||||
r.Get("/tags", tagListHandler)
|
||||
r.Route("/auth", func(r chi.Router) {
|
||||
r.Post("/login", authHandler.Login)
|
||||
r.Post("/refresh", authHandler.Refresh)
|
||||
|
||||
Reference in New Issue
Block a user