forked from Ptt-official-app/Ptt-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (34 loc) · 1.09 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
package main
import (
"github.com/Ptt-official-app/Ptt-backend/internal/config"
"github.com/Ptt-official-app/Ptt-backend/internal/delivery/http"
"github.com/Ptt-official-app/Ptt-backend/internal/logging"
"github.com/Ptt-official-app/Ptt-backend/internal/repository"
"github.com/Ptt-official-app/Ptt-backend/internal/usecase"
"github.com/Ptt-official-app/go-bbs"
_ "github.com/Ptt-official-app/go-bbs/pttbbs"
)
func main() {
logger := logging.NewLogger()
logger.Informationalf("server start")
globalConfig, err := config.NewDefaultConfig()
if err != nil {
logger.Errorf("failed to get config: %v", err)
return
}
db, err := bbs.Open("pttbbs", globalConfig.BBSHome)
if err != nil {
logger.Errorf("open bbs db error: %v", err)
return
}
repo, err := repository.NewRepository(db)
if err != nil {
logger.Errorf("failed to create user repository: %s\n", err)
return
}
usecase := usecase.NewUsecase(globalConfig, repo)
httpDelivery := http.NewHTTPDelivery(usecase)
if err := httpDelivery.Run(globalConfig.ListenPort); err != nil {
logger.Errorf("run http delivery error: %s\n", err)
}
}