IOServer Documentation๏
Welcome to IOServer - a powerful, production-ready framework for building real-time applications with HTTP and WebSocket support.
Contents:
Quick Overview๏
IOServer combines the speed of Fastify with the real-time capabilities of Socket.IO, providing a unified architecture for modern web applications. Built with TypeScript and designed for scalability, it offers a clean separation of concerns through services, controllers, managers, and watchers.
Key Features๏
๐ High Performance - Built on Fastify for maximum HTTP throughput
โก Real-time Communication - Integrated Socket.IO for WebSocket connections
๐๏ธ Modular Architecture - Clean separation with Services, Controllers, Managers, and Watchers
๐ Security First - Built-in CORS, error handling, and validation
๐ TypeScript Native - Full type safety and IntelliSense support
๐งช Fully Tested - Comprehensive test suite with 95%+ coverage
๐ง Configuration Driven - JSON-based routing and flexible configuration
๐ฆ Production Ready - Memory leak detection, performance monitoring, and error handling
Installation๏
npm install @ioserver/core
# or
yarn add @ioserver/core
Quick Start๏
import { IOServer, BaseService, BaseController } from '@ioserver/core';
// Create a service for real-time functionality
class ChatService extends BaseService {
async sendMessage(socket: any, data: any, callback?: Function) {
socket.broadcast.emit('new_message', data);
if (callback) callback({ status: 'success' });
}
}
// Create a controller for HTTP endpoints
class ApiController extends BaseController {
async getStatus(request: any, reply: any) {
reply.send({ status: 'OK', timestamp: Date.now() });
}
}
// Initialize and configure server
const server = new IOServer({
host: 'localhost',
port: 3000,
});
// Register components
server.addService({ name: 'chat', service: ChatService });
server.addController({ name: 'api', controller: ApiController });
// Start server
await server.start();