feat: Swagger API 문서 추가 + 보스레이드/플레이어 레벨 시스템
- swaggo/swag 기반 전체 API 엔드포인트 Swagger 어노테이션 (59개) - /swagger/ 경로에 Swagger UI 제공 - 보스레이드 데디서버 관리 (등록, 하트비트, 슬롯 리셋) - 플레이어 레벨/경험치 시스템 및 스탯 성장 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
32
main.go
32
main.go
@@ -15,6 +15,8 @@ import (
|
||||
"a301_server/internal/download"
|
||||
"a301_server/internal/player"
|
||||
|
||||
_ "a301_server/docs" // swagger docs
|
||||
|
||||
"github.com/tolelom/tolchain/core"
|
||||
"a301_server/pkg/config"
|
||||
"a301_server/pkg/database"
|
||||
@@ -27,6 +29,22 @@ import (
|
||||
"github.com/gofiber/fiber/v2/middleware/logger"
|
||||
)
|
||||
|
||||
// @title One of the Plans API
|
||||
// @version 1.0
|
||||
// @description 멀티플레이어 보스 레이드 게임 플랫폼 백엔드 API
|
||||
// @host a301.api.tolelom.xyz
|
||||
// @BasePath /
|
||||
|
||||
// @securityDefinitions.apikey BearerAuth
|
||||
// @in header
|
||||
// @name Authorization
|
||||
// @description JWT Bearer 토큰 (예: Bearer eyJhbGci...)
|
||||
|
||||
// @securityDefinitions.apikey ApiKeyAuth
|
||||
// @in header
|
||||
// @name X-API-Key
|
||||
// @description 내부 API 키 (게임 서버 ↔ API 서버 통신용)
|
||||
|
||||
func main() {
|
||||
config.Load()
|
||||
config.WarnInsecureDefaults()
|
||||
@@ -37,7 +55,7 @@ func main() {
|
||||
log.Println("MySQL 연결 성공")
|
||||
|
||||
// AutoMigrate
|
||||
if err := database.DB.AutoMigrate(&auth.User{}, &announcement.Announcement{}, &download.Info{}, &chain.UserWallet{}, &bossraid.BossRoom{}, &player.PlayerProfile{}); err != nil {
|
||||
if err := database.DB.AutoMigrate(&auth.User{}, &announcement.Announcement{}, &download.Info{}, &chain.UserWallet{}, &bossraid.BossRoom{}, &bossraid.DedicatedServer{}, &bossraid.RoomSlot{}, &player.PlayerProfile{}); err != nil {
|
||||
log.Fatalf("AutoMigrate 실패: %v", err)
|
||||
}
|
||||
|
||||
@@ -106,6 +124,9 @@ func main() {
|
||||
_, err := chainSvc.GrantRewardByUsername(username, tokenAmount, assets)
|
||||
return err
|
||||
})
|
||||
brSvc.SetExpGranter(func(username string, exp int) error {
|
||||
return playerSvc.GrantExperienceByUsername(username, exp)
|
||||
})
|
||||
brHandler := bossraid.NewHandler(brSvc)
|
||||
|
||||
if config.C.InternalAPIKey == "" {
|
||||
@@ -196,6 +217,15 @@ func main() {
|
||||
|
||||
routes.Register(app, authHandler, annHandler, dlHandler, chainHandler, brHandler, playerHandler, authLimiter, apiLimiter, healthCheck, readyCheck, chainUserLimiter)
|
||||
|
||||
// Background: stale dedicated server detection
|
||||
go func() {
|
||||
ticker := time.NewTicker(15 * time.Second)
|
||||
defer ticker.Stop()
|
||||
for range ticker.C {
|
||||
brSvc.CheckStaleSlots()
|
||||
}
|
||||
}()
|
||||
|
||||
// Graceful shutdown
|
||||
go func() {
|
||||
sigCh := make(chan os.Signal, 1)
|
||||
|
||||
Reference in New Issue
Block a user