Refactor password hashing to follow DIP and improve CI/CD
- Create PasswordHasher interface in domain layer - Implement BcryptHasher in infrastructure layer - Update RegisterUserHandler and LoginUserHandler to use interface - Remove bcrypt dependency from application layer - Update main.go and integration tests with dependency injection - Enhance CI/CD workflow with test and lint jobs - Add code coverage check (minimum 50%) - Add go vet and gofmt validation - Configure build job to depend on test and lint passing - Update GitHub Actions to latest versions (v4→v5) This achieves 100% SOLID compliance (DIP) and ensures Clean Architecture by removing external library dependencies from application/domain layers.
This commit is contained in:
+4
-2
@@ -11,6 +11,7 @@ import (
|
||||
"apocapoc-api/internal/application/queries"
|
||||
"apocapoc-api/internal/infrastructure/auth"
|
||||
"apocapoc-api/internal/infrastructure/config"
|
||||
"apocapoc-api/internal/infrastructure/crypto"
|
||||
httpInfra "apocapoc-api/internal/infrastructure/http"
|
||||
"apocapoc-api/internal/infrastructure/persistence/sqlite"
|
||||
)
|
||||
@@ -52,13 +53,14 @@ func main() {
|
||||
}
|
||||
|
||||
jwtService := auth.NewJWTService(cfg.JWTSecret, jwtExpiryHours)
|
||||
passwordHasher := crypto.NewBcryptHasher()
|
||||
|
||||
userRepo := sqlite.NewUserRepository(db.Conn())
|
||||
habitRepo := sqlite.NewHabitRepository(db.Conn())
|
||||
entryRepo := sqlite.NewHabitEntryRepository(db.Conn())
|
||||
|
||||
registerHandler := commands.NewRegisterUserHandler(userRepo)
|
||||
loginHandler := queries.NewLoginUserHandler(userRepo)
|
||||
registerHandler := commands.NewRegisterUserHandler(userRepo, passwordHasher)
|
||||
loginHandler := queries.NewLoginUserHandler(userRepo, passwordHasher)
|
||||
createHandler := commands.NewCreateHabitHandler(habitRepo)
|
||||
getTodaysHandler := queries.NewGetTodaysHabitsHandler(habitRepo, entryRepo)
|
||||
getUserHabitsHandler := queries.NewGetUserHabitsHandler(habitRepo)
|
||||
|
||||
Reference in New Issue
Block a user