56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
// 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/loghandler"
|
||
"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)
|
||
|
||
// checking for deletable logs on startup
|
||
loghandler.CheckForDeletableLogs()
|
||
|
||
// starting the background log deleter
|
||
go loghandler.StartBackgroundLogDeleter()
|
||
}
|
||
|
||
func main() {
|
||
app := fiber.New(fiber.Config{
|
||
BodyLimit: 100 * 1024 * 1024,
|
||
})
|
||
|
||
app.Use(cors.New(cors.Config{}))
|
||
|
||
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)
|
||
}
|