-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (37 loc) · 1.11 KB
/
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 (
"fmt"
"github.com/gofiber/contrib/swagger"
"log"
"github.com/ManuelReschke/PixelFox/internal/pkg/database"
"github.com/ManuelReschke/PixelFox/internal/pkg/env"
"github.com/ManuelReschke/PixelFox/internal/pkg/router"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/fiber/v2/middleware/monitor"
"github.com/gofiber/fiber/v2/middleware/recover"
"github.com/gofiber/template/html/v2"
)
func main() {
app := NewApplication()
err := app.Listen(fmt.Sprintf("%s:%s", env.GetEnv("APP_HOST", "localhost"), env.GetEnv("APP_PORT", "4000")))
log.Fatal(err)
}
func NewApplication() *fiber.App {
env.SetupEnvFile()
database.SetupDatabase()
engine := html.New("./views", ".html")
app := fiber.New(fiber.Config{Views: engine})
app.Use(recover.New(), logger.New())
app.Get("/metrics", monitor.New())
app.Static("/", "./public/assets")
// SWAGGER / OPENAPI
openAPICfg := swagger.Config{
BasePath: "/docs/api/",
FilePath: "./public/docs/v1/openapi.yml",
Path: "v1",
}
app.Use(swagger.New(openAPICfg))
router.InstallRouter(app)
return app
}