-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (28 loc) · 954 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
package main
import (
"bootcamp-course-microservice/infras"
"bootcamp-course-microservice/internal/repository"
"bootcamp-course-microservice/internal/services"
"bootcamp-course-microservice/transport/middleware"
"bootcamp-course-microservice/transport/routes"
"fmt"
"net/http"
)
func main() {
// Create a new database connection
db := infras.ProvideConn()
// Initialize the repository with the database connection
repo := repository.ProvideRepo(&db)
// Initialize the service with the repository
svc := services.ProvideService(repo)
// Initialize the authentication middleware
secretKey := []byte("your-secret-key")
auth := middleware.ProvideAuthentication(&db, secretKey)
// Initialize the router with the service and authentication
r := routes.ProvideRouter(svc, auth)
fmt.Println("Starting server on :8081")
err := http.ListenAndServe(":8081", r.SetupRoutes())
if err != nil {
fmt.Printf("Error: %s\n", err.Error())
}
}