setup user/auth repository and service
This commit is contained in:
parent
8db61212d9
commit
0ae9cd7133
7 changed files with 249 additions and 4 deletions
|
|
@ -5,12 +5,16 @@ import (
|
|||
|
||||
"git.juancwu.dev/juancwu/budgething/internal/config"
|
||||
"git.juancwu.dev/juancwu/budgething/internal/db"
|
||||
"git.juancwu.dev/juancwu/budgething/internal/repository"
|
||||
"git.juancwu.dev/juancwu/budgething/internal/service"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
Cfg *config.Config
|
||||
DB *sqlx.DB
|
||||
Cfg *config.Config
|
||||
DB *sqlx.DB
|
||||
UserService *service.UserService
|
||||
AuthService *service.AuthService
|
||||
}
|
||||
|
||||
func New(cfg *config.Config) (*App, error) {
|
||||
|
|
@ -24,9 +28,16 @@ func New(cfg *config.Config) (*App, error) {
|
|||
return nil, fmt.Errorf("failed to run migrations: %w", err)
|
||||
}
|
||||
|
||||
userRepository := repository.NewUserRepository(database)
|
||||
|
||||
userService := service.NewUserService(userRepository)
|
||||
authService := service.NewAuthService(userRepository)
|
||||
|
||||
return &App{
|
||||
Cfg: cfg,
|
||||
DB: database,
|
||||
Cfg: cfg,
|
||||
DB: database,
|
||||
UserService: userService,
|
||||
AuthService: authService,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue