-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (34 loc) · 891 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
43
44
45
package main
import (
"go-auth/config"
"go-auth/database"
"go-auth/routes"
"go-auth/sessions"
"log"
"os"
"github.com/ansrivas/fiberprometheus/v2"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/logger"
)
func init() {
// load environment variables from a `.env` file
config.MustLoadEnvVariables()
// connect to a postgres database and start migrations
database.MustInit()
// initialize the redis sessions store
sessions.MustInitRedisStore()
}
func main() {
app := fiber.New()
app.Use(cors.New(cors.Config{
AllowOrigins: os.Getenv("FRONT_URL"),
AllowCredentials: true,
}))
prometheus := fiberprometheus.New("go-auth-api")
prometheus.RegisterAt(app, "/metrics")
app.Use(logger.New())
app.Use(prometheus.Middleware)
routes.AttachAuthRoutesV1(app)
log.Fatalln(app.Listen(":5050"))
}