42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/gofiber/fiber/v2/middleware/cors"
|
|
"github.com/gofiber/fiber/v2/middleware/helmet"
|
|
"github.com/gofiber/fiber/v2/middleware/logger"
|
|
|
|
"cloud.etaviaporte.com/api/libs/services/auth"
|
|
)
|
|
|
|
func main() {
|
|
app := fiber.New()
|
|
|
|
app.Use(cors.New(cors.Config{
|
|
AllowOrigins: "https://api.etaviaporte.com, http://127.0.0.1, http://localhost",
|
|
AllowHeaders: "Origin, Content-Type, Accept, Authorization",
|
|
AllowMethods: "GET, POST, HEAD, PUT, DELETE, PATCH",
|
|
AllowCredentials: true,
|
|
}))
|
|
|
|
app.Use(logger.New(logger.Config{
|
|
Format: "[${ip}]:${port} ${status} - ${method} ${path}\n",
|
|
}))
|
|
|
|
app.Use(helmet.New())
|
|
|
|
app.Get("/", func(c *fiber.Ctx) error {
|
|
return c.SendString("Hello, World!")
|
|
})
|
|
|
|
handler := auth.Handler{}
|
|
// openapi.RegisterHandlers(app, auth.Handler{})
|
|
|
|
app.Post("/auth/login", handler.PostAuthLogin)
|
|
app.Post("/auth/logout", handler.PostAuthLogout)
|
|
app.Get("/auth/me", handler.GetAuthMe)
|
|
app.Post("/auth/refresh", handler.PostAuthRefresh)
|
|
|
|
app.Listen(":3000")
|
|
}
|