Overview
The module provides a TypeScript-based framework that compiles to Lua using roblox-ts, enabling airline games to connect with the SkyTeam API and display real-time information to players. Package:@skyteam/modelsLocation:
apps/modelsLanguage: TypeScript (compiled to Lua)
Technology Stack
- Language: TypeScript with roblox-ts compiler
- UI Framework: Roact (React for ROBLOX)
- Build Tool: roblox-ts v3.0
- Project Manager: Rojo for syncing to ROBLOX Studio
- Type Definitions: @rbxts/types, @rbxts/compiler-types
Project Structure
Architecture
SkyTeamModule Class
The main module class (src/module/index.ts:29) initializes the SkyTeam system:
apps/models/src/module/index.ts
Server-Side Loader
The loader script (src/loader/main.server.ts:1) instantiates and initializes the module:
apps/models/src/loader/main.server.ts
Client Runtime
The client script (src/module/client/index.client.tsx:1) handles client-side events:
apps/models/src/module/client/index.client.tsx
Event Communication
Type-safe event system (src/module/shared/CommunicationTypes.d.ts:1):
apps/models/src/module/shared/CommunicationTypes.d.ts
Usage in Games
Basic Setup
- Install Module: Place compiled module in ReplicatedStorage
- Configure Token: Set airline API token in loader script
- Initialize: Call
.Initialize()on server start
Event Handling
The module communicates via RemoteEvent:- Server → Client: Initialization errors, status updates
- Client → Server: User actions, data requests
- Type Safety: TypeScript ensures correct event data types
UI Components
Error Display
The module includes a Roact-based error UI that displays initialization failures:Future Components
Planned UI components:- Miles Display: Show player’s SkyTeam miles
- Flight Info: Current flight details and status
- Rewards Shop: Browse and purchase miles products
- Alliance Info: View connected airlines
Development
Scripts
Build Process
- TypeScript Compilation: roblox-ts compiles
.tsfiles to.lua - Rojo Sync: Rojo syncs compiled files to ROBLOX Studio
- Type Checking: TypeScript validates types before compilation
Dependencies
apps/models/package.json
API Integration
The module connects to the SkyTeam API (src/module/index.ts:31):
- Fetching user data and miles
- Recording flight activity
- Validating purchases
- Syncing airline information
Service Testing
The module validates HTTP connectivity on initialization (src/module/index.ts:75):
- HTTP requests are enabled in game settings
- Network connectivity is available
- API endpoints are reachable
Error Handling
Initialization Errors
If initialization fails:- Error is logged to server console
- Error message stored in
InitalizationError - All clients receive error via RemoteEvent
- Client displays error UI to players
- New players joining also see the error
Graceful Degradation
When API is unavailable:- Game continues to function normally
- SkyTeam features are disabled
- Clear error message shown to players
- Automatic retry on next server restart
Security Considerations
Token Protection
- Airline tokens should be stored server-side only
- Never expose tokens to client scripts
- Rotate tokens regularly
- Use environment-specific tokens (dev/prod)
Client Validation
- All client requests validated on server
- API calls only from server scripts
- Rate limiting on API endpoints
- Input sanitization for user data
Rojo Configuration
The module uses Rojo for project management (default.project.json):
Future Features
- Real-time Flight Tracking: Sync active flights to API
- Miles Earning: Award miles for completed flights
- In-Game Shop: Purchase upgrades with miles
- Alliance Notifications: Broadcast alliance-wide messages
- Player Statistics: Track and display flight history
- Achievements: Unlock rewards for milestones
TypeScript Benefits
Type Safety
Autocomplete & IntelliSense
- Full IDE support in VS Code
- Autocomplete for ROBLOX APIs
- Inline documentation from type definitions
- Refactoring support (rename, extract, etc.)
Modern JavaScript Features
- Async/await for asynchronous operations
- Arrow functions and destructuring
- Template literals
- Optional chaining and nullish coalescing