-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (41 loc) · 1.43 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
package main
import (
"log"
"net/http"
"time"
"github.com/decagonhq/meddle-api/config"
"github.com/decagonhq/meddle-api/db"
"github.com/decagonhq/meddle-api/server"
"github.com/decagonhq/meddle-api/services"
)
func main() {
http.DefaultClient.Timeout = time.Second * 10
conf, err := config.Load()
if err != nil {
log.Fatal(err)
}
gormDB := db.GetDB(conf)
authRepo := db.NewAuthRepo(gormDB)
mail := services.NewMailService(conf)
notificationRepo := db.NewNotificationRepo(gormDB)
pushNotification, errr := services.NewFirebaseCloudMessaging(notificationRepo, conf)
if err != nil {
log.Fatalf("error retrieving client for push notification\n%v", errr)
}
authService := services.NewAuthService(authRepo, conf, mail, pushNotification)
medicationHistoryRepo := db.NewMedicationHistoryRepo(gormDB)
medicationRepo := db.NewMedicationRepo(gormDB)
medicationService := services.NewMedicationService(medicationRepo, medicationHistoryRepo, conf)
medicationHistoryService := services.NewMedicationHistoryService(medicationHistoryRepo, conf)
s := &server.Server{
Config: conf,
AuthRepository: authRepo,
AuthService: authService,
MedicationService: medicationService,
MedicationHistoryService: medicationHistoryService,
PushNotification: pushNotification,
}
go services.UpdateMedicationCronJob(medicationService)
go pushNotification.NotificationsCronJob()
s.Start()
}