add user management functionality with OTP verification and consent handling, DI introduced
This commit is contained in:
@ -1,28 +1,57 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
authApi "git.logidex.ru/fakz9/logidex-id/internal/api/auth/handler"
|
||||
"context"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"git.logidex.ru/fakz9/logidex-id/internal/api/auth"
|
||||
"git.logidex.ru/fakz9/logidex-id/internal/api/user"
|
||||
"git.logidex.ru/fakz9/logidex-id/internal/config"
|
||||
"git.logidex.ru/fakz9/logidex-id/internal/db"
|
||||
"git.logidex.ru/fakz9/logidex-id/internal/hydra_client"
|
||||
"git.logidex.ru/fakz9/logidex-id/internal/redis"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"strconv"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
||||
func main() {
|
||||
config.Init()
|
||||
err := redis.Init()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
hydra_client.InitClient()
|
||||
|
||||
func NewFiberApp(cfg config.Config) *fiber.App {
|
||||
app := fiber.New()
|
||||
api := app.Group("/api")
|
||||
authApi.RegisterApp(api)
|
||||
|
||||
err = app.Listen(":" + strconv.Itoa(config.Cfg.App.Port))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return app
|
||||
}
|
||||
|
||||
func StartFiberApp(lifecycle fx.Lifecycle, app *fiber.App, cfg config.Config) {
|
||||
lifecycle.Append(fx.Hook{
|
||||
OnStart: func(ctx context.Context) error {
|
||||
go func() {
|
||||
if err := app.Listen(":" + strconv.Itoa(cfg.App.Port)); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
},
|
||||
OnStop: func(ctx context.Context) error {
|
||||
return app.Shutdown()
|
||||
},
|
||||
})
|
||||
}
|
||||
func NewFiberRouter(app *fiber.App) fiber.Router {
|
||||
return app.Group("/api")
|
||||
}
|
||||
|
||||
func main() {
|
||||
fx.New(
|
||||
fx.Provide(
|
||||
config.NewConfig,
|
||||
redis.NewRedisClient,
|
||||
hydra_client.NewHydraClient,
|
||||
NewFiberApp,
|
||||
NewFiberRouter,
|
||||
),
|
||||
db.Module,
|
||||
user.Module,
|
||||
auth.Module,
|
||||
fx.Invoke(StartFiberApp),
|
||||
).Run()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user