-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (31 loc) · 758 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
package main
import (
routes "go_jwt/router"
"go_jwt/src/database"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
)
func main() {
app := fiber.New()
app.Use(logger.New())
setupRoutes(app)
app.Listen(":6001")
}
func setupRoutes(app *fiber.App) {
// start database
database.StartMongoDB()
// // defer closing database
// defer database.CloseMongoDB()
// give response when at /
app.Get("/", func(c *fiber.Ctx) error {
return c.Status(fiber.StatusOK).JSON(fiber.Map{
"success": true,
"message": "You are at the endpoint 😉",
})
})
// api group
api := app.Group("/api")
routes.AdminRoute(api.Group("/admins"))
routes.UserRoute(api.Group("/users"))
//routes.AuthRoute(api.Group("/auth"))
}