-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (33 loc) · 851 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
package main
import (
"go-fiber-auth-api/controllers"
"go-fiber-auth-api/db"
"go-fiber-auth-api/repository"
"go-fiber-auth-api/routes"
"log"
"net/http"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/joho/godotenv"
)
func init() {
err := godotenv.Load()
if err != nil {
log.Panicln(err)
}
}
func main() {
conn := db.NewConnection()
app := fiber.New()
app.Use(cors.New())
app.Use(logger.New())
app.Get("/", func(ctx *fiber.Ctx) error {
return ctx.Status(http.StatusOK).JSON(fiber.Map{"message": "Hello World"})
})
usersRepo := repository.NewUsersRepository(conn)
authController := controllers.NewAuthController(usersRepo)
authRoutes := routes.NewAuthRoutes(authController)
authRoutes.Install(app)
log.Fatal(app.Listen(":8080"))
}