// App-Idea Rest-API Documentation
//
// Example Swagger spec.
//
//	Schemes: [http, https]
//	BasePath: /api/v1/
//	Version: 0.0.1
//	Contact: Alex<alex@roese.dev>
//
//	Consumes:
//	- application/json
//
//	Produces:
//	- application/json
//
//      SecurityDefinitions:
//          api_key:
//              type: apiKey
//              name: Authorization
//              in: header
// swagger:meta
package main

import (
	"git.umbach.dev/app-idea/rest-api/modules/config"
	"git.umbach.dev/app-idea/rest-api/modules/database"
	"git.umbach.dev/app-idea/rest-api/modules/rabbitmq"
	"git.umbach.dev/app-idea/rest-api/routers/router"

	"github.com/gofiber/fiber/v2"

	log "github.com/sirupsen/logrus"
)

func main() {
	app := fiber.New()
	/*
		app.Use(cors.New(cors.Config{
			AllowOrigins:     "http://10.0.2.16, http://127.0.0.1, http://192.168.178.53, http://0.0.0.0",
			AllowHeaders:     "Origin, Content-Type, Accept",
			AllowCredentials: true,
		})) */

	config.LoadConfig()

	cfg := &config.Cfg.Server

	if cfg.Debug {
		log.SetLevel(log.DebugLevel)
	}

	router.SetupRoutes(app)

	database.InitDatabase()

	rabbitmq.Init()

	app.Listen(cfg.Host)
}

/*
	ToDo:
	- update user password and delete his sessions
*/
