-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (30 loc) · 897 Bytes
/
main.go
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
40
41
42
package main
import (
"log"
"github.com/Elvis-Benites-N/GolangChat/db"
"github.com/Elvis-Benites-N/GolangChat/internal/user"
"github.com/Elvis-Benites-N/GolangChat/internal/ws"
"github.com/Elvis-Benites-N/GolangChat/router"
)
func main() {
// Initialize the database connection
dbConn, err := db.NewDatabase()
if err != nil {
log.Fatalf("Could not initialize the database connection: %s", err)
}
// Create the user repository
userRep := user.NewRepository(dbConn.GetDB())
// Create the user service
userSvc := user.NewService(userRep)
// Create the user handler
userHandler := user.NewHandler(userSvc)
// Create the WebSocket hub
hub := ws.NewHub()
// Create the WebSocket handler
wsHandler := ws.NewHandler(hub)
// Run the WebSocket hub
go hub.Run()
// Initialize and start the router
router.InitRouter(userHandler, wsHandler)
router.Start("0.0.0.0:4200")
}