package main

import (
	configs "learnsteam/learsteam-quiz-api/configs"
	_ "learnsteam/learsteam-quiz-api/docs"
	"learnsteam/learsteam-quiz-api/internal/database"
	"learnsteam/learsteam-quiz-api/internal/helpers"
	"learnsteam/learsteam-quiz-api/internal/routers"

	"log"
	"net/http"

	"github.com/apex/gateway"
)

// @title Learsteam Quiz API
// @version 1.0
// @description Learnsteam Quiz 서비스 API

// @contact.name Jay Sheen
// @contact.email sheen@jongyeob.com

func main() {
	Init()
	Run()
}

func Init() {
	database.Init()
	routers.Init()

	database.AutoMigrate()
}

func Run() {
	if helpers.InLambda() {
		log.Fatal(gateway.ListenAndServe(configs.PORT, routers.Router))
	} else {
		log.Fatal(http.ListenAndServe(configs.PORT, routers.Router))
	}
}

func InitSwagger() {
	// swagger:route GET /health health
	// Check server health
	//
	// responses:
	//   200: healthResponse
}
