fix: remove redundante names

This commit is contained in:
2024-12-04 23:22:25 +01:00
parent 2d5f42bb28
commit 5ef59df2d0
16 changed files with 228 additions and 230 deletions

28
main.go
View File

@@ -44,7 +44,7 @@ func run(ctx context.Context, database *sql.DB, env func(string) string) {
log.Info("Starting server...")
// init server settings
serverSettings := types.NewServerSettingsFromEnv(env)
serverSettings := types.NewSettingsFromEnv(env)
// init db
err := db.RunMigrations(database, "")
@@ -101,33 +101,31 @@ func shutdownServer(s *http.Server, ctx context.Context, wg *sync.WaitGroup) {
}
}
func createHandler(d *sql.DB, serverSettings *types.ServerSettings) http.Handler {
func createHandler(d *sql.DB, serverSettings *types.Settings) http.Handler {
var router = http.NewServeMux()
authDb := db.NewAuthDbSqlite(d)
authDb := db.NewAuthSqlite(d)
workoutDb := db.NewWorkoutDbSqlite(d)
randomService := service.NewRandomServiceImpl()
clockService := service.NewClockServiceImpl()
mailService := service.NewMailServiceImpl(serverSettings)
randomService := service.NewRandomImpl()
clockService := service.NewClockImpl()
mailService := service.NewMailImpl(serverSettings)
authService := service.NewAuthServiceImpl(authDb, randomService, clockService, mailService, serverSettings)
workoutService := service.NewWorkoutServiceImpl(workoutDb, randomService, clockService, mailService, serverSettings)
authService := service.NewAuthImpl(authDb, randomService, clockService, mailService, serverSettings)
workoutService := service.NewWorkoutImpl(workoutDb, randomService, clockService, mailService, serverSettings)
render := handler.NewRender(serverSettings)
indexHandler := handler.NewIndexHandler(authService, render)
authHandler := handler.NewHandlerAuth(authService, render)
workoutHandler := handler.NewWorkoutHandler(workoutService, authService, render)
indexHandler := handler.NewIndex(authService, render)
authHandler := handler.NewAuth(authService, render)
workoutHandler := handler.NewWorkout(workoutService, authService, render)
indexHandler.Handle(router)
workoutHandler.Handle(router)
authHandler.Handle(router)
// Serve static files (CSS, JS and images)
router.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static/"))))
workoutHandler.Handle(router)
authHandler.Handle(router)
return middleware.Wrapper(
router,
middleware.Log,