package main import ( "github.com/jackc/pgx/v5/pgxpool" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "osdb/internal/handler" "osdb/internal/repository" ) // New creates and configures the Echo instance with all routes registered. func New(pool *pgxpool.Pool) *echo.Echo { e := echo.New() e.HideBanner = true e.Use(middleware.Logger()) e.Use(middleware.Recover()) health := handler.NewHealthHandler() // Root health — used by docker healthcheck + ops tooling e.GET("/health", health.Health) // Versioned API group api := e.Group("/api/v1") api.GET("/health", health.Health) // Fruits (story #02) fruitRepo := repository.NewFruitRepo(pool) fruits := handler.NewFruitHandler(fruitRepo) g := api.Group("/fruits") g.GET("", fruits.List) g.POST("", fruits.Create) g.GET("/:id", fruits.Get) g.PUT("/:id", fruits.Update) g.DELETE("/:id", fruits.Delete) g.GET("/:id/images", fruits.ListImages) g.POST("/:id/images", fruits.UploadImage, middleware.BodyLimit("5M")) g.GET("/:id/images/:imageId", fruits.ServeImage) g.DELETE("/:id/images/:imageId", fruits.DeleteImage) return e }