0.0.2
This commit is contained in:
parent
853120f4ee
commit
3696d08136
@ -9,6 +9,7 @@ import (
|
|||||||
import (
|
import (
|
||||||
"donat-widget/infrastructure/pg"
|
"donat-widget/infrastructure/pg"
|
||||||
"donat-widget/infrastructure/weed"
|
"donat-widget/infrastructure/weed"
|
||||||
|
AuthClient "donat-widget/pkg/api/auth"
|
||||||
PaymentClient "donat-widget/pkg/api/payment"
|
PaymentClient "donat-widget/pkg/api/payment"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -30,6 +31,7 @@ func main() {
|
|||||||
|
|
||||||
// CLIENTS
|
// CLIENTS
|
||||||
paymentClient := PaymentClient.New(cfg.PaymentService.Host, cfg.PaymentService.Port)
|
paymentClient := PaymentClient.New(cfg.PaymentService.Host, cfg.PaymentService.Port)
|
||||||
|
authClient := AuthClient.New(cfg.AuthService.Host, cfg.AuthService.Port)
|
||||||
|
|
||||||
// REPOSITORIES
|
// REPOSITORIES
|
||||||
widgetRepo := WidgetRepo.New(db, storage)
|
widgetRepo := WidgetRepo.New(db, storage)
|
||||||
@ -46,5 +48,6 @@ func main() {
|
|||||||
widgetService,
|
widgetService,
|
||||||
donatService,
|
donatService,
|
||||||
targetService,
|
targetService,
|
||||||
|
authClient,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ func NewApp(
|
|||||||
widgetService model.WidgetService,
|
widgetService model.WidgetService,
|
||||||
donatService model.DonatService,
|
donatService model.DonatService,
|
||||||
targetService model.TargetService,
|
targetService model.TargetService,
|
||||||
|
authClient model.AuthClient,
|
||||||
) {
|
) {
|
||||||
server := echo.New()
|
server := echo.New()
|
||||||
server.Validator = validator.NewValidator()
|
server.Validator = validator.NewValidator()
|
||||||
@ -35,9 +36,9 @@ func NewApp(
|
|||||||
server.GET(PREFIX+"/table/create", CreateTale(db))
|
server.GET(PREFIX+"/table/create", CreateTale(db))
|
||||||
server.GET(PREFIX+"/table/drop", DropTale(db))
|
server.GET(PREFIX+"/table/drop", DropTale(db))
|
||||||
|
|
||||||
IncludeWidgetHandlers(server, widgetService)
|
IncludeWidgetHandlers(server, widgetService, authClient)
|
||||||
IncludeDonatHandlers(server, donatService)
|
IncludeDonatHandlers(server, donatService)
|
||||||
IncludeTargetHandlers(server, targetService, donatService)
|
IncludeTargetHandlers(server, targetService, donatService, authClient)
|
||||||
|
|
||||||
server.Logger.Fatal(server.Start(":8002"))
|
server.Logger.Fatal(server.Start(":8002"))
|
||||||
}
|
}
|
||||||
@ -46,8 +47,9 @@ func IncludeTargetHandlers(
|
|||||||
server *echo.Echo,
|
server *echo.Echo,
|
||||||
targetService model.TargetService,
|
targetService model.TargetService,
|
||||||
donatService model.DonatService,
|
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.GET(PREFIX+"/target/all", GetAllTarget(targetService))
|
||||||
server.POST(PREFIX+"/target/addAmount", AddAmountTarget(targetService, donatService))
|
server.POST(PREFIX+"/target/addAmount", AddAmountTarget(targetService, donatService))
|
||||||
}
|
}
|
||||||
@ -64,8 +66,9 @@ func IncludeDonatHandlers(
|
|||||||
func IncludeWidgetHandlers(
|
func IncludeWidgetHandlers(
|
||||||
server *echo.Echo,
|
server *echo.Echo,
|
||||||
widgetService model.WidgetService,
|
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+"/html/:widgetID", GetWidgetHTML(widgetService))
|
||||||
server.GET(PREFIX+"/info/:widgetID", GetWidgetInfo(widgetService))
|
server.GET(PREFIX+"/info/:widgetID", GetWidgetInfo(widgetService))
|
||||||
server.PATCH(PREFIX+"/duration/update", UpdateDuration(widgetService))
|
server.PATCH(PREFIX+"/duration/update", UpdateDuration(widgetService))
|
||||||
|
@ -9,6 +9,7 @@ type Config struct {
|
|||||||
Db Database `yaml:"db"`
|
Db Database `yaml:"db"`
|
||||||
Storage Storage `yaml:"storage"`
|
Storage Storage `yaml:"storage"`
|
||||||
PaymentService PaymentService `yaml:"paymentService"`
|
PaymentService PaymentService `yaml:"paymentService"`
|
||||||
|
AuthService AuthService `yaml:"authService"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Database struct {
|
type Database struct {
|
||||||
@ -29,6 +30,11 @@ type PaymentService struct {
|
|||||||
Port string `yaml:"port"`
|
Port string `yaml:"port"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AuthService struct {
|
||||||
|
Host string `yaml:"host"`
|
||||||
|
Port string `yaml:"port"`
|
||||||
|
}
|
||||||
|
|
||||||
func Init() *Config {
|
func Init() *Config {
|
||||||
data, err := os.ReadFile("internal/config/config.yaml")
|
data, err := os.ReadFile("internal/config/config.yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -14,4 +14,8 @@ storage:
|
|||||||
|
|
||||||
paymentService:
|
paymentService:
|
||||||
host: "92.118.114.148"
|
host: "92.118.114.148"
|
||||||
port: "8003"
|
port: "8003"
|
||||||
|
|
||||||
|
authService:
|
||||||
|
host: "donat-auth"
|
||||||
|
port: "8001"
|
Loading…
x
Reference in New Issue
Block a user