-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (33 loc) · 769 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 (
"context"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"go.mongodb.org/mongo-driver/mongo"
"jwt-golang/database"
"jwt-golang/routes"
"log"
)
const (
port = ":3000"
)
func main() {
app := fiber.New()
app.Use(logger.New())
routes.Router(app)
//routesStack := app.Stack()
client := database.Client
// connect to mongodb
//Client := database.ConnectWithMongodb()
// close the connection
defer func(client *mongo.Client, ctx context.Context) {
err := client.Disconnect(ctx)
if err != nil {
log.Fatal(err)
}
}(client, context.Background())
// listen to the port + start the server
if err := app.Listen(port); err != nil {
log.Fatal("Error starting the server: ", err.Error())
}
}