package main

import (
	"git.kanopo.dev/rhythm/rhythm-backend/internal/config"
	"git.kanopo.dev/rhythm/rhythm-backend/internal/db"
	usersdb "git.kanopo.dev/rhythm/rhythm-backend/internal/db/users"
	"git.kanopo.dev/rhythm/rhythm-backend/internal/http"
	"git.kanopo.dev/rhythm/rhythm-backend/internal/http/api/auth"
	"git.kanopo.dev/rhythm/rhythm-backend/internal/http/api/health"
	"git.kanopo.dev/rhythm/rhythm-backend/internal/logger"
	"git.kanopo.dev/rhythm/rhythm-backend/internal/service/users"
	"go.uber.org/fx"
	"go.uber.org/fx/fxevent"
	"go.uber.org/zap"
)

func main() {
	fx.New(
		fx.Provide(
			config.Provide,       //config
			logger.ProvideLogger, //logger
			db.ProvidePool,       // pool provider
			usersdb.New,          // generated code for sqlc
			users.NewService,     // service
			http.NewServer,       // http server
			health.NewHandler,    // http handler
			auth.NewHandler,      //http handler
		),
		fx.Invoke(
			http.GlueRoutes,
		),
		fx.WithLogger(func(logger *zap.Logger) fxevent.Logger {
			return &fxevent.ZapLogger{Logger: logger}
		}),
	).Run()
}
