-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
39 lines (33 loc) · 1.07 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
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/fiber/v2/middleware/recover"
"github.com/hananloser/rest-fiber-mongo-2/config"
"github.com/hananloser/rest-fiber-mongo-2/controller"
"github.com/hananloser/rest-fiber-mongo-2/exception"
"github.com/hananloser/rest-fiber-mongo-2/repository"
"github.com/hananloser/rest-fiber-mongo-2/service/user"
)
func main() {
// Setup Database
configuration := config.New()
database := config.NewMongoDatabase(configuration)
// Setup repository
userRepository := repository.NewUserRepository(database)
//For ignore variable
_ = repository.NewProductRepository(database)
// Setup Service
userService := service_user.NewUserService(&userRepository)
//Setup Controller
userController := controller.NewUserController(userService)
// Setup Fiber
app := fiber.New(config.NewFiberConfig())
app.Use(logger.New())
app.Use(recover.New())
// Register The Route
userController.Route(app)
// Running THE APP
err := app.Listen(":8000")
exception.PanicIfNeeded(err)
}