// Package classification JNX Log Manager API Documentation.
//
// Schemes: https
// Host: jannex
// BasePath: /v1
// Version: 1.0.0
//
// Consumes:
// - application/json
//
// Produces:
// - application/json
//
// swagger:meta
package main

import (
	"jannex/log-manager/modules/config"
	"jannex/log-manager/modules/utils"
	"jannex/log-manager/routers/router"

	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/middleware/cors"
	"github.com/gofiber/fiber/v2/middleware/logger"
)

func init() {
	config.LoadConfig()
	utils.ValidatorInit()

	utils.CreateDirectoryIfNotExists(config.Cfg.LogFolder)
}

func main() {
	app := fiber.New(fiber.Config{
		BodyLimit: 100 * 1024 * 1024,
	})

	app.Use(cors.New())

	app.Use(logger.New(logger.Config{
		Format: "${pid} ${locals:requestid} ${status} - ${latency} ${method} ${path}​\n",
	}))

	router.SetupRoutes(app)

	app.Listen(config.Cfg.Host + ":" + config.Cfg.Port)
}
