-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (35 loc) · 891 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
43
44
45
46
package main
import (
"fbgr/config"
"fbgr/controller"
"fbgr/model"
"fbgr/repository"
"fbgr/router"
"fbgr/service"
"fmt"
"log"
"github.com/go-playground/validator/v10"
"github.com/gofiber/fiber/v2"
)
func main() {
fmt.Print("Run service ...")
loadConfig, err := config.LoadConfig(".")
if err != nil {
log.Fatal("could not load environment variables", err)
}
// Database
db := config.ConnectionDB(&loadConfig)
validate := validator.New()
db.Table("notes").AutoMigrate(&model.Note{})
// Init Repository
noteRepository := repository.NewNoteRepositoryImpl(db)
// Init Service
noteService := service.NewNoteServiceImpl(noteRepository, validate)
// Init Controller
noteController := controller.NewNoteController(noteService)
// Routes
routes := router.NewRouter(noteController)
app := fiber.New()
app.Mount("/api", routes)
log.Fatal(app.Listen(":7000"))
}