2023-10-19 22:47:12 +09:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-11-17 01:38:01 +09:00
|
|
|
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"
|
|
|
|
|
2023-10-19 22:47:12 +09:00
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/apex/gateway"
|
|
|
|
)
|
|
|
|
|
2023-11-17 01:38:01 +09:00
|
|
|
// @title Learsteam Quiz API
|
|
|
|
// @version 1.0
|
|
|
|
// @description Learnsteam Quiz 서비스 API
|
|
|
|
|
|
|
|
// @contact.name Jay Sheen
|
|
|
|
// @contact.email sheen@jongyeob.com
|
|
|
|
|
2023-10-19 22:47:12 +09:00
|
|
|
func main() {
|
|
|
|
Init()
|
|
|
|
Run()
|
|
|
|
}
|
|
|
|
|
|
|
|
func Init() {
|
|
|
|
database.Init()
|
|
|
|
routers.Init()
|
2023-11-17 01:38:01 +09:00
|
|
|
|
2023-10-19 22:47:12 +09:00
|
|
|
database.AutoMigrate()
|
|
|
|
}
|
|
|
|
|
|
|
|
func Run() {
|
|
|
|
if helpers.InLambda() {
|
|
|
|
log.Fatal(gateway.ListenAndServe(configs.PORT, routers.Router))
|
|
|
|
} else {
|
|
|
|
log.Fatal(http.ListenAndServe(configs.PORT, routers.Router))
|
|
|
|
}
|
|
|
|
}
|
2023-11-17 01:38:01 +09:00
|
|
|
|
|
|
|
func InitSwagger() {
|
|
|
|
// swagger:route GET /health health
|
|
|
|
// Check server health
|
|
|
|
//
|
|
|
|
// responses:
|
|
|
|
// 200: healthResponse
|
|
|
|
}
|