package main import ( "git.gocasts.ir/ebhomengo/niki/adapter/redis" smsprovider "git.gocasts.ir/ebhomengo/niki/adapter/sms_provider" "git.gocasts.ir/ebhomengo/niki/config" httpserver "git.gocasts.ir/ebhomengo/niki/delivery/http_server" "git.gocasts.ir/ebhomengo/niki/repository/mysql" mysqlbenefactor "git.gocasts.ir/ebhomengo/niki/repository/mysql/benefactor" redisotp "git.gocasts.ir/ebhomengo/niki/repository/redis/redis_otp" authservice "git.gocasts.ir/ebhomengo/niki/service/auth/benefactor" benefactorservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/benefactor" benefactorvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/benefactor" _ "github.com/go-sql-driver/mysql" ) func main() { cfg := config.C() // TODO - add command for migrations // mgr := migrator.New(cfg.Mysql) // mgr.Up() _, benefactorSvc, benefactorVld := setupServices(cfg) server := httpserver.New(cfg, benefactorSvc, benefactorVld) server.Serve() } func setupServices(cfg config.Config) ( authSvc authservice.Service, benefactorSvc benefactorservice.Service, benefactorVld benefactorvalidator.Validator, ) { authSvc = authservice.New(cfg.Auth) MysqlRepo := mysql.New(cfg.Mysql) redisAdapter := redis.New(cfg.Redis) RedisOtp := redisotp.New(redisAdapter) benefactorMysql := mysqlbenefactor.New(MysqlRepo) smsProvider := smsprovider.New(cfg.SmsProvider) authGenerator := authservice.New(cfg.Auth) benefactorSvc = benefactorservice.New(cfg.BenefactorSvc, RedisOtp, smsProvider, authGenerator, benefactorMysql) benefactorVld = benefactorvalidator.New() return authSvc, benefactorSvc, benefactorVld }