refactor: replace gorm with vanilla sql and sqlc

This commit is contained in:
Stavros
2025-12-24 20:17:41 +02:00
parent 7269fa1b95
commit c8e86d8536
16 changed files with 366 additions and 159 deletions

View File

@@ -1,6 +1,7 @@
package bootstrap
import (
"tinyauth/internal/repository"
"tinyauth/internal/service"
"github.com/rs/zerolog/log"
@@ -9,27 +10,14 @@ import (
type Services struct {
accessControlService *service.AccessControlsService
authService *service.AuthService
databaseService *service.DatabaseService
dockerService *service.DockerService
ldapService *service.LdapService
oauthBrokerService *service.OAuthBrokerService
}
func (app *BootstrapApp) initServices() (Services, error) {
func (app *BootstrapApp) initServices(queries *repository.Queries) (Services, error) {
services := Services{}
databaseService := service.NewDatabaseService(service.DatabaseServiceConfig{
DatabasePath: app.config.DatabasePath,
})
err := databaseService.Init()
if err != nil {
return Services{}, err
}
services.databaseService = databaseService
ldapService := service.NewLdapService(service.LdapServiceConfig{
Address: app.config.Ldap.Address,
BindDN: app.config.Ldap.BindDN,
@@ -39,7 +27,7 @@ func (app *BootstrapApp) initServices() (Services, error) {
SearchFilter: app.config.Ldap.SearchFilter,
})
err = ldapService.Init()
err := ldapService.Init()
if err == nil {
services.ldapService = ldapService
@@ -76,7 +64,7 @@ func (app *BootstrapApp) initServices() (Services, error) {
LoginTimeout: app.config.Auth.LoginTimeout,
LoginMaxRetries: app.config.Auth.LoginMaxRetries,
SessionCookieName: app.context.sessionCookieName,
}, dockerService, ldapService, databaseService.GetDatabase())
}, dockerService, ldapService, queries)
err = authService.Init()