package fiber import ( cache "git.dmitriygnatenko.ru/dima/go-common/cache/ttl_memory_cache" "git.dmitriygnatenko.ru/dima/go-common/db" "github.com/gofiber/fiber/v2" "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/repositories" "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/auth" "git.dmitriygnatenko.ru/dima/dmitriygnatenko-v2/internal/services/config" ) const ( appName = "dmitriygnatenko" templatesPath = "./../../internal/templates" staticPath = "../../web" metricsURI = "/metrics" ) type ServiceProvider interface { ConfigService() *config.Service AuthService() *auth.Service CacheService() *cache.Cache TransactionManager() *db.TxManager ArticleRepository() *repositories.ArticleRepository TagRepository() *repositories.TagRepository ArticleTagRepository() *repositories.ArticleTagRepository UserRepository() *repositories.UserRepository } func Init(sp ServiceProvider) (*fiber.App, error) { fiberApp := fiber.New(getConfig(sp)) initStatic(fiberApp) initMetrics(fiberApp, sp) initMiddleware(fiberApp, sp) initPublicHandlers(fiberApp, sp) initAdminHandlers(fiberApp, sp) return fiberApp, nil } func getConfig(sp ServiceProvider) fiber.Config { return fiber.Config{ AppName: appName, DisableStartupMessage: true, Views: getViewsEngine(sp), ErrorHandler: getErrorHandler(), } }