package fiber

import (
	"github.com/gofiber/fiber/v2"

	"git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/service/handler"
)

func initPublicHandlers(app *fiber.App, sp ServiceProvider) {
	mainPageHandler := handler.NewMainPageHandler(
		sp.CacheService(),
		sp.ArticleRepository(),
	)

	app.Get("/:lang<regex(^en$)>", mainPageHandler)
	app.Get("/", mainPageHandler)

	tagPageHandler := handler.NewTagPageHandler(
		sp.CacheService(),
		sp.ArticleRepository(),
		sp.TagRepository(),
	)

	app.Get("/:lang<regex(^en$)>/tag/:tag", tagPageHandler)
	app.Get("/tag/:tag", tagPageHandler)

	articlePageHandler := handler.NewArticlePageHandler(
		sp.CacheService(),
		sp.ArticleRepository(),
		sp.TagRepository(),
	)

	app.Get("/:lang<regex(^en$)>/article/:article", articlePageHandler)
	app.Get("/article/:article", articlePageHandler)
}
