2023-12-16 07:20:01 +00:00
|
|
|
package main
|
2023-12-15 08:24:06 +00:00
|
|
|
|
2024-01-14 15:53:37 +00:00
|
|
|
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"
|
2024-01-15 10:33:24 +00:00
|
|
|
_ "github.com/go-sql-driver/mysql"
|
2024-01-14 15:53:37 +00:00
|
|
|
)
|
|
|
|
|
2023-12-16 06:09:50 +00:00
|
|
|
func main() {
|
2024-01-14 15:53:37 +00:00
|
|
|
cfg := config.C()
|
|
|
|
|
|
|
|
// TODO - add command for migrations
|
2024-01-15 10:33:24 +00:00
|
|
|
// mgr := migrator.New(cfg.Mysql)
|
|
|
|
// mgr.Up()
|
2024-01-14 15:53:37 +00:00
|
|
|
|
|
|
|
_, benefactorSvc, benefactorVld := setupServices(cfg)
|
|
|
|
server := httpserver.New(cfg, benefactorSvc, benefactorVld)
|
|
|
|
server.Serve()
|
|
|
|
}
|
|
|
|
|
|
|
|
func setupServices(cfg config.Config) (
|
2024-01-15 10:33:24 +00:00
|
|
|
authSvc authservice.Service, benefactorSvc benefactorservice.Service, benefactorVld benefactorvalidator.Validator,
|
2024-01-14 15:53:37 +00:00
|
|
|
) {
|
2024-01-15 10:33:24 +00:00
|
|
|
authSvc = authservice.New(cfg.Auth)
|
2024-01-14 15:53:37 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2024-01-15 10:33:24 +00:00
|
|
|
benefactorSvc = benefactorservice.New(cfg.BenefactorSvc, RedisOtp, smsProvider, authGenerator, benefactorMysql)
|
2024-01-14 15:53:37 +00:00
|
|
|
|
2024-01-15 10:33:24 +00:00
|
|
|
benefactorVld = benefactorvalidator.New()
|
2024-01-14 15:53:37 +00:00
|
|
|
|
|
|
|
return authSvc, benefactorSvc, benefactorVld
|
2023-12-15 08:24:06 +00:00
|
|
|
}
|