This commit is contained in:
mm 2024-10-23 10:34:10 +05:00
parent 853120f4ee
commit 3696d08136
4 changed files with 21 additions and 5 deletions

View File

@ -9,6 +9,7 @@ import (
import (
"donat-widget/infrastructure/pg"
"donat-widget/infrastructure/weed"
AuthClient "donat-widget/pkg/api/auth"
PaymentClient "donat-widget/pkg/api/payment"
)
@ -30,6 +31,7 @@ func main() {
// CLIENTS
paymentClient := PaymentClient.New(cfg.PaymentService.Host, cfg.PaymentService.Port)
authClient := AuthClient.New(cfg.AuthService.Host, cfg.AuthService.Port)
// REPOSITORIES
widgetRepo := WidgetRepo.New(db, storage)
@ -46,5 +48,6 @@ func main() {
widgetService,
donatService,
targetService,
authClient,
)
}

View File

@ -27,6 +27,7 @@ func NewApp(
widgetService model.WidgetService,
donatService model.DonatService,
targetService model.TargetService,
authClient model.AuthClient,
) {
server := echo.New()
server.Validator = validator.NewValidator()
@ -35,9 +36,9 @@ func NewApp(
server.GET(PREFIX+"/table/create", CreateTale(db))
server.GET(PREFIX+"/table/drop", DropTale(db))
IncludeWidgetHandlers(server, widgetService)
IncludeWidgetHandlers(server, widgetService, authClient)
IncludeDonatHandlers(server, donatService)
IncludeTargetHandlers(server, targetService, donatService)
IncludeTargetHandlers(server, targetService, donatService, authClient)
server.Logger.Fatal(server.Start(":8002"))
}
@ -46,8 +47,9 @@ func IncludeTargetHandlers(
server *echo.Echo,
targetService model.TargetService,
donatService model.DonatService,
authClient model.AuthClient,
) {
server.POST(PREFIX+"/target/create", CreateTarget(targetService))
server.POST(PREFIX+"/target/create", CreateTarget(targetService, authClient))
server.GET(PREFIX+"/target/all", GetAllTarget(targetService))
server.POST(PREFIX+"/target/addAmount", AddAmountTarget(targetService, donatService))
}
@ -64,8 +66,9 @@ func IncludeDonatHandlers(
func IncludeWidgetHandlers(
server *echo.Echo,
widgetService model.WidgetService,
authClient model.AuthClient,
) {
server.POST(PREFIX+"/create", CreateWidget(widgetService))
server.POST(PREFIX+"/create", CreateWidget(widgetService, authClient))
server.GET(PREFIX+"/html/:widgetID", GetWidgetHTML(widgetService))
server.GET(PREFIX+"/info/:widgetID", GetWidgetInfo(widgetService))
server.PATCH(PREFIX+"/duration/update", UpdateDuration(widgetService))

View File

@ -9,6 +9,7 @@ type Config struct {
Db Database `yaml:"db"`
Storage Storage `yaml:"storage"`
PaymentService PaymentService `yaml:"paymentService"`
AuthService AuthService `yaml:"authService"`
}
type Database struct {
@ -29,6 +30,11 @@ type PaymentService struct {
Port string `yaml:"port"`
}
type AuthService struct {
Host string `yaml:"host"`
Port string `yaml:"port"`
}
func Init() *Config {
data, err := os.ReadFile("internal/config/config.yaml")
if err != nil {

View File

@ -14,4 +14,8 @@ storage:
paymentService:
host: "92.118.114.148"
port: "8003"
port: "8003"
authService:
host: "donat-auth"
port: "8001"