package biz

import (
	"github.com/nose7en/ToyBoomServer/biz/user"
	"github.com/nose7en/ToyBoomServer/common"
	"github.com/nose7en/ToyBoomServer/config"
	"github.com/nose7en/ToyBoomServer/middleware"

	"github.com/gin-gonic/gin"
)

func Router() *gin.Engine {
	r := gin.Default()

	api := r.Group("/api")
	v1 := api.Group("/v1")

	userRouter := v1.Group("/user")
	{
		userRouter.POST("/login-with-apple", middleware.ValidateAppleAppLoginCode(), common.Wrapper(user.LoginWithApple))
		userRouter.GET("/info", middleware.ValidateToken(), common.Wrapper(user.GetUserInfo))
	}

	if config.IsDebug() {
		// for debug
		v1.GET("/ping", middleware.ValidateToken(), func(ctx *gin.Context) { ctx.JSON(200, gin.H{"message": "pong"}) })
	}
	return r
}