-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (34 loc) · 842 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
package main
import (
"auth/config"
"auth/injector"
"fmt"
"log"
"os"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/joho/godotenv"
)
func main() {
if err := godotenv.Load(); err != nil {
log.Fatal(err)
}
conns := config.NewConn()
user := conns.UserConn()
customer := conns.CustomerConn()
port := os.Getenv("PORT")
app := fiber.New()
app.Use(cors.New(cors.Config{
AllowCredentials: true,
ExposeHeaders: "Retry-After",
}))
injector.NewAuthInjector(app)
// some routes use jwt here
injector.NewAdminInjector(app, user)
// customer
customerRoute := app.Group("customer")
customerApi := customerRoute.Group("api")
injector.NewCustomerInjector(customerApi, customer)
fmt.Printf("⚡️[server]: Server is running on port %s\n", port)
log.Fatal(app.Listen(port))
}