-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
39 lines (31 loc) · 1 KB
/
main.go
File metadata and controls
39 lines (31 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"log"
"github.com/yarieldis/guebapi/config"
"github.com/yarieldis/guebapi/internal/api/handlers"
"github.com/yarieldis/guebapi/internal/api/router"
"github.com/yarieldis/guebapi/internal/repository/user"
"github.com/yarieldis/guebapi/internal/service/auth"
)
func main() {
// Load configuration
cfg := config.Load()
// Initialize repository with default users
userRepo := user.NewMemoryRepositoryWithData(map[string]string{
"john": "password123",
"jane": "password456",
})
// Initialize services
authService := auth.NewJWTService(userRepo, cfg.JWT.SecretKey, cfg.JWT.TokenDuration)
// Initialize handlers
authHandler := handlers.NewAuthHandler(authService)
profileHandler := handlers.NewProfileHandler(userRepo)
// Setup router
r := router.SetupRouter(authHandler, profileHandler, authService)
// Start server
addr := cfg.Server.Address()
log.Printf("Starting server on %s", addr)
if err := r.Run(addr); err != nil {
log.Fatalf("Failed to start server: %v", err)
}
}