@dapex-tech/elite-online-services
v0.0.6
Published
A client library to connect with the **Elite Online App**. This package provides a simple interface to request information from the **Elite Online REST API**.
Readme
📦 @dapex-tech/elite-online-services
A client library to connect with the Elite Online App.
This package provides a simple interface to request information from the Elite Online REST API.
🛠 API Coverage
This client includes typed interfaces for the Elite Online REST API, including:
- MainService → Core endpoints of Elite Online App
- SocketService → Real-time events (if enabled)
- CancelablePromise → Control async requests
- Request utilities → Custom API requests
🚀 Installation
Using npm:
npm install @dapex-tech/elite-online-servicesUsing Yarn:
yarn add @dapex-tech/elite-online-services🔑 Authentication
Before making requests, configure the client with your API key or auth token (depending on how the Elite Online App issues credentials).
import { OpenAPI } from '@dapex-tech/elite-online-services';
OpenAPI.TOKEN = 'your_api_token_here';
OpenAPI.BASE = 'https://api.eliteonlineapp.com';📘 Usage Example
Import the client
import { MainService } from '@dapex-tech/elite-online-services';Make a request
async function run() {
try {
const data = await MainService.getUserProfile({ userId: 123 });
console.log('User profile:', data);
} catch (error) {
console.error('API error:', error);
}
}
run();🔌 Socket Usage
This package includes a SocketService class that wraps socket.io-client and provides convenient methods to work with real-time events.
Import and Connect
import { SocketService } from '@dapex-tech/elite-online-services';
const socket = new SocketService('https://your-api-base-url');
// Connect to the socket
socket.connect();
// Disconnect when done
// socket.disconnect();Sending and Receiving Messages
// Send a message
socket.sendMessage('Hello world!');
// Listen for incoming messages
socket.onMessageReceived((data) => {
console.log('Message received:', data.text);
});Updating and Listening to Location Events
// Emit a location update
socket.updateLocation({ lat: 35.9185, lng: -110.7258, clientID: '12345' });
// Listen for location updates from the server
socket.onLocationUpdated((data) => {
console.log('Location updated:', data);
});
// Listen for all active client locations
socket.onAllLocations((locations) => {
console.log('All locations:', locations);
});Removing Listeners
// Remove a specific listener
socket.offMessageReceived(myMessageHandler);
// Or remove all listeners for an event
socket.off('locationUpdated');⚙️ Configuration
You can configure global client settings via OpenAPI:
import { OpenAPI } from '@dapex-tech/elite-online-services';
OpenAPI.BASE = 'https://api.eliteonlineapp.com';
OpenAPI.TOKEN = 'my-secret-token';
OpenAPI.WITH_CREDENTIALS = true;📄 TypeScript Support
The client is written in TypeScript, so you get full type definitions out of the box.
import { ApiResult } from '@dapex-tech/elite-online-services';
const result: ApiResult = {
ok: true,
status: 200,
body: { message: 'success' },
};🤝 Contributing
Contributions are welcome!
- Fork the repo
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -m 'Add new feature') - Push to your branch (
git push origin feature/my-feature) - Open a Pull Request
📜 License
MIT © 2025 Dapex Tech
