-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (42 loc) · 1.31 KB
/
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
43
44
45
46
47
48
49
package main
import (
"log"
"time"
internal "github.com/martingallauner/bookclub/internal"
"github.com/martingallauner/bookclub/internal/auth"
"github.com/martingallauner/bookclub/internal/client"
"github.com/martingallauner/bookclub/internal/collections"
repository "github.com/martingallauner/bookclub/internal/repository"
bcServer "github.com/martingallauner/bookclub/internal/server"
"github.com/martingallauner/bookclub/internal/users"
)
func main() {
auth.NewAuth()
dbConfig, err := internal.ReadDatabaseConfig()
if err != nil {
log.Fatal(err)
}
db, err := internal.SetupDatabase(dbConfig)
if err != nil {
log.Fatal(err)
}
client := client.NewClient(5 * time.Second)
bookRepository := &repository.PostgresBookRepository{Database: db}
userRepository := &repository.PostgresUserRepository{Database: db}
linkRepository := &repository.PostgresLinkRepository{Database: db}
collectionService := collections.New(userRepository, bookRepository, linkRepository, client)
userService := users.New(userRepository, bookRepository, linkRepository, client)
server := bcServer.New(
client,
bookRepository,
userRepository,
linkRepository,
&internal.GothicAuthService{},
&internal.JwtServiceImpl{},
collectionService,
userService)
err = bcServer.StartServer(server)
if err != nil {
log.Fatal(err)
}
}