All checks were successful
Server CI/CD / deploy (push) Successful in 7s
- internal/chain 패키지 추가 (client, handler, service, repository, model) - 체인 연동 엔드포인트: 지갑 조회, 잔액, 자산, 인벤토리, 마켓 등 - 관리자 전용 체인 엔드포인트: 민팅, 보상, 템플릿 등록 - 게임 서버용 내부 API (/api/internal/chain/*) + ServerAuth 미들웨어 - 회원가입 시 블록체인 월렛 자동 생성 - 체인 관련 환경변수 및 InternalAPIKey 설정 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
73 lines
1.8 KiB
Go
73 lines
1.8 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
type Config struct {
|
|
AppPort string
|
|
DBHost string
|
|
DBPort string
|
|
DBUser string
|
|
DBPassword string
|
|
DBName string
|
|
RedisAddr string
|
|
RedisPassword string
|
|
JWTSecret string
|
|
JWTExpiryHours int
|
|
AdminUsername string
|
|
AdminPassword string
|
|
BaseURL string
|
|
GameDir string
|
|
|
|
// Chain integration
|
|
ChainNodeURL string
|
|
ChainID string
|
|
OperatorKeyHex string
|
|
WalletEncryptionKey string
|
|
|
|
// Server-to-server auth
|
|
InternalAPIKey string
|
|
}
|
|
|
|
var C Config
|
|
|
|
func Load() {
|
|
_ = godotenv.Load()
|
|
|
|
hours, _ := strconv.Atoi(getEnv("JWT_EXPIRY_HOURS", "24"))
|
|
C = Config{
|
|
AppPort: getEnv("APP_PORT", "8080"),
|
|
DBHost: getEnv("DB_HOST", "localhost"),
|
|
DBPort: getEnv("DB_PORT", "3306"),
|
|
DBUser: getEnv("DB_USER", "root"),
|
|
DBPassword: getEnv("DB_PASSWORD", ""),
|
|
DBName: getEnv("DB_NAME", "a301"),
|
|
RedisAddr: getEnv("REDIS_ADDR", "localhost:6379"),
|
|
RedisPassword: getEnv("REDIS_PASSWORD", ""),
|
|
JWTSecret: getEnv("JWT_SECRET", "secret"),
|
|
JWTExpiryHours: hours,
|
|
AdminUsername: getEnv("ADMIN_USERNAME", "admin"),
|
|
AdminPassword: getEnv("ADMIN_PASSWORD", "admin1234"),
|
|
BaseURL: getEnv("BASE_URL", "http://localhost:8080"),
|
|
GameDir: getEnv("GAME_DIR", "/data/game"),
|
|
|
|
ChainNodeURL: getEnv("CHAIN_NODE_URL", "http://localhost:8545"),
|
|
ChainID: getEnv("CHAIN_ID", "tolchain-dev"),
|
|
OperatorKeyHex: getEnv("OPERATOR_KEY_HEX", ""),
|
|
WalletEncryptionKey: getEnv("WALLET_ENCRYPTION_KEY", ""),
|
|
|
|
InternalAPIKey: getEnv("INTERNAL_API_KEY", ""),
|
|
}
|
|
}
|
|
|
|
func getEnv(key, fallback string) string {
|
|
if v := os.Getenv(key); v != "" {
|
|
return v
|
|
}
|
|
return fallback
|
|
}
|