package main import ( "git.gocasts.ir/ebhomengo/niki/adapter/redis" smsprovider "git.gocasts.ir/ebhomengo/niki/adapter/sms_provider/kavenegar" kavenegarotp "git.gocasts.ir/ebhomengo/niki/adapter/sms_provider/kavenegar/otp" "git.gocasts.ir/ebhomengo/niki/config" httpserver "git.gocasts.ir/ebhomengo/niki/delivery/http_server" "git.gocasts.ir/ebhomengo/niki/repository/migrator" "git.gocasts.ir/ebhomengo/niki/repository/mysql" mysqladdress "git.gocasts.ir/ebhomengo/niki/repository/mysql/address" mysqlbenefactor "git.gocasts.ir/ebhomengo/niki/repository/mysql/benefactor" mysqlkindboxreq "git.gocasts.ir/ebhomengo/niki/repository/mysql/kind_box_req" redisotp "git.gocasts.ir/ebhomengo/niki/repository/redis/redis_otp" authservice "git.gocasts.ir/ebhomengo/niki/service/auth/benefactor" benefactoraddressservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/address" benefactorservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/benefactor" benefactorkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box_req" benefactorvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/benefactor" benefactorkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/kind_box_req" _ "github.com/go-sql-driver/mysql" ) func main() { cfg := config.C() // TODO - add command for migrations mgr := migrator.New(cfg.Mysql) mgr.Up() authSvc, benefactorSvc, benefactorVld, benefactorKindBoxReqSvc, benefactorKindBoxReqVld := setupServices(cfg) server := httpserver.New(cfg, benefactorSvc, benefactorVld, authSvc, benefactorKindBoxReqSvc, benefactorKindBoxReqVld) server.Serve() } //nolint:nakedret // we are sure of this func setupServices(cfg config.Config) ( authSvc authservice.Service, benefactorSvc benefactorservice.Service, benefactorVld benefactorvalidator.Validator, benefactorKindBoxReqSvc benefactorkindboxreqservice.Service, benefactorKindBoxReqVld benefactorkindboxreqvalidator.Validator, ) { authSvc = authservice.New(cfg.Auth) MysqlRepo := mysql.New(cfg.Mysql) redisAdapter := redis.New(cfg.Redis) RedisOtp := redisotp.New(redisAdapter) benefactorMysql := mysqlbenefactor.New(MysqlRepo) kavenegarSmsProvider := smsprovider.New(cfg.KavenegarSmsProvider) otpSmsProvider := kavenegarotp.New(kavenegarSmsProvider) authGenerator := authservice.New(cfg.Auth) benefactorSvc = benefactorservice.New(cfg.BenefactorSvc, RedisOtp, otpSmsProvider, authGenerator, benefactorMysql) benefactorVld = benefactorvalidator.New() benefactorkindBoxReqMysql := mysqlkindboxreq.New(MysqlRepo) benefactorKindBoxReqSvc = benefactorkindboxreqservice.New(benefactorkindBoxReqMysql) benefactorAddressMysql := mysqladdress.New(MysqlRepo) benefactorAddressSvc := benefactoraddressservice.New(benefactorAddressMysql) benefactorKindBoxReqVld = benefactorkindboxreqvalidator.New(benefactorkindBoxReqMysql, benefactorSvc, benefactorAddressSvc) return }