Files
csgowtf/.env.example
vikingowl d811efc394 feat: complete Phase 3 - Domain Modeling & Data Layer
Implements comprehensive type system, runtime validation, API client,
and testing infrastructure for CS2.WTF.

TypeScript Interfaces (src/lib/types/):
- Match.ts: Match, MatchPlayer, MatchListItem types
- Player.ts: Player, PlayerMeta, PlayerProfile types
- RoundStats.ts: Round economy and performance data
- Weapon.ts: Weapon statistics with hit groups (HitGroup, WeaponType enums)
- Message.ts: Chat messages with filtering support
- api.ts: API responses, errors, and APIException class
- Complete type safety with strict null checks

Zod Schemas (src/lib/schemas/):
- Runtime validation for all data models
- Schema parsers with safe/unsafe variants
- Special handling for backend typo (looses → losses)
- Share code validation regex
- CS2-specific validations (rank 0-30000, MR12 rounds)

API Client (src/lib/api/):
- client.ts: Axios-based HTTP client with error handling
  - Request cancellation support (AbortController)
  - Automatic retry logic for transient failures
  - Timeout handling (10s default)
  - Typed APIException errors
- players.ts: Player endpoints (profile, meta, track/untrack, search)
- matches.ts: Match endpoints (parse, details, weapons, rounds, chat, search)
- Zod validation on all API responses

MSW Mock Handlers (src/mocks/):
- fixtures.ts: Comprehensive mock data for testing
- handlers/players.ts: Mock player API endpoints
- handlers/matches.ts: Mock match API endpoints
- browser.ts: Browser MSW worker for development
- server.ts: Node MSW server for Vitest tests
- Realistic responses with delays and pagination
- Safe integer IDs to avoid precision loss

Configuration:
- .env.example: Complete environment variable documentation
- src/vite-env.d.ts: Vite environment type definitions
- All strict TypeScript checks passing (0 errors, 0 warnings)

Features:
- Cancellable requests for search (prevent race conditions)
- Data normalization (backend typo handling)
- Comprehensive error types (NetworkError, Timeout, etc.)
- Share code parsing and validation
- Pagination support for players and matches
- Mock data for offline development and testing

Build Status: ✓ Production build successful
Type Check: ✓ 0 errors, 0 warnings
Lint: ✓ All checks passed
Phase 3 Completion: 100%

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 20:31:20 +01:00

80 lines
2.3 KiB
Plaintext

# CS2.WTF Environment Configuration
# Copy this file to .env for local development
# DO NOT commit .env to version control
# ============================================
# API Configuration
# ============================================
# Backend API Base URL
# Default: http://localhost:8000 (local development)
# Production: https://api.csgow.tf or your backend URL
VITE_API_BASE_URL=http://localhost:8000
# API request timeout in milliseconds
# Default: 10000 (10 seconds)
VITE_API_TIMEOUT=10000
# ============================================
# Feature Flags
# ============================================
# Enable live match updates (polling/WebSocket)
# Default: false
VITE_ENABLE_LIVE_MATCHES=false
# Enable analytics tracking
# Default: true (respects user consent)
VITE_ENABLE_ANALYTICS=true
# Enable debug mode (verbose logging, dev tools)
# Default: false
VITE_DEBUG_MODE=false
# ============================================
# Analytics & Tracking (Optional)
# ============================================
# Plausible Analytics
# Only required if analytics is enabled
# VITE_PLAUSIBLE_DOMAIN=cs2.wtf
# VITE_PLAUSIBLE_API_HOST=https://plausible.io
# Umami Analytics (alternative)
# VITE_UMAMI_WEBSITE_ID=your-website-id
# VITE_UMAMI_SRC=https://analytics.example.com/script.js
# ============================================
# Experimental Features
# ============================================
# Enable WebGL-based heatmaps (high performance)
# Default: false (use Canvas fallback)
# VITE_ENABLE_WEBGL_HEATMAPS=false
# Enable MSW API mocking in development
# Useful for frontend development without backend
# Default: false
# VITE_ENABLE_MSW_MOCKING=false
# ============================================
# Build Configuration
# ============================================
# App version (auto-populated from package.json)
# VITE_APP_VERSION=2.0.0
# Build timestamp (auto-populated during build)
# VITE_BUILD_TIMESTAMP=2024-11-04T12:00:00Z
# ============================================
# SSR/Deployment (Advanced)
# ============================================
# Public base URL for the application
# Used for canonical URLs, sitemaps, etc.
# PUBLIC_BASE_URL=https://cs2.wtf
# Origin whitelist for CORS (if handling API in same domain)
# PUBLIC_CORS_ORIGINS=https://cs2.wtf,https://www.cs2.wtf