ioserver 1.5.3 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,656 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview IOServer - A TypeScript framework for building real-time applications
4
+ * with Socket.IO and Fastify integration. Provides modular architecture with
5
+ * Services, Controllers, Managers, and Watchers.
6
+ *
7
+ * @author Ben Mz <0x42en@users.noreply.github.com>
8
+ * @version 2.0.0
9
+ * @since 1.0.0
10
+ */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
24
+ }) : function(o, v) {
25
+ o["default"] = v;
26
+ });
27
+ var __importStar = (this && this.__importStar) || (function () {
28
+ var ownKeys = function(o) {
29
+ ownKeys = Object.getOwnPropertyNames || function (o) {
30
+ var ar = [];
31
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
+ return ar;
33
+ };
34
+ return ownKeys(o);
35
+ };
36
+ return function (mod) {
37
+ if (mod && mod.__esModule) return mod;
38
+ var result = {};
39
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
+ __setModuleDefault(result, mod);
41
+ return result;
42
+ };
43
+ })();
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.IOServer = void 0;
49
+ const fs = __importStar(require("fs"));
50
+ const path = __importStar(require("path"));
51
+ const promises_1 = require("timers/promises");
52
+ const fastify_1 = __importDefault(require("fastify"));
53
+ const socket_io_1 = require("socket.io");
54
+ const cors_1 = __importDefault(require("@fastify/cors"));
55
+ const sensible_1 = __importDefault(require("@fastify/sensible"));
56
+ const IOServerError_1 = require("./IOServerError");
57
+ /**
58
+ * Main IOServer class - A framework for building real-time applications
59
+ *
60
+ * Combines Fastify HTTP server with Socket.IO for WebSocket support,
61
+ * providing a modular architecture with Services, Controllers, Managers, and Watchers.
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const server = new IOServer({
66
+ * host: 'localhost',
67
+ * port: 3000,
68
+ * verbose: 'INFO'
69
+ * });
70
+ *
71
+ * server.addService({ service: ChatService });
72
+ * server.addController({ name: 'api', controller: ApiController });
73
+ * await server.start();
74
+ * ```
75
+ */
76
+ class IOServer {
77
+ /**
78
+ * Creates a new IOServer instance
79
+ * @param {IOServerOptions} options - Configuration options for the server
80
+ */
81
+ constructor(options = {}) {
82
+ this.serviceLists = new Map();
83
+ this.managerLists = new Map();
84
+ this.methodLists = new Map();
85
+ this.watcherLists = new Map();
86
+ this.controllerLists = new Map();
87
+ this.middlewareLists = new Map();
88
+ this.host = options.host || IOServer.DEFAULT_HOST;
89
+ this.port = this.validatePort(options.port || IOServer.DEFAULT_PORT);
90
+ this.verbose = this.validateLogLevel(options.verbose || 'ERROR');
91
+ const defaultRoutes = path.join(process.cwd(), 'routes');
92
+ this.routesPath =
93
+ options.routes && fs.existsSync(options.routes)
94
+ ? options.routes
95
+ : defaultRoutes;
96
+ const transportModes = this.processTransportModes(options.mode);
97
+ const corsOptions = this.processCorsOptions(options.cors);
98
+ const cookieEnabled = Boolean(options.cookie);
99
+ this.webapp = this.initializeFastify();
100
+ this.setupPlugins(corsOptions);
101
+ this.setupSocketIO(transportModes, cookieEnabled, corsOptions);
102
+ this.appHandle = {
103
+ send: this.sendTo.bind(this),
104
+ log: this.log.bind(this),
105
+ verbose: this.verbose,
106
+ };
107
+ }
108
+ validatePort(port) {
109
+ const numPort = Number(port);
110
+ if (isNaN(numPort) || numPort <= 0 || numPort > 65535) {
111
+ throw new IOServerError_1.IOServerError('Invalid port number', 400);
112
+ }
113
+ return numPort;
114
+ }
115
+ validateLogLevel(level) {
116
+ const upperLevel = level.toUpperCase();
117
+ return IOServer.LOG_LEVELS.includes(upperLevel) ? upperLevel : 'ERROR';
118
+ }
119
+ processTransportModes(mode) {
120
+ if (!mode) {
121
+ return ['websocket', 'polling'];
122
+ }
123
+ const modes = [];
124
+ if (typeof mode === 'string') {
125
+ if (IOServer.TRANSPORTS.includes(mode)) {
126
+ modes.push(mode);
127
+ }
128
+ }
129
+ else if (Array.isArray(mode)) {
130
+ mode.forEach(m => {
131
+ if (IOServer.TRANSPORTS.includes(m)) {
132
+ modes.push(m);
133
+ }
134
+ });
135
+ }
136
+ return modes.length > 0 ? modes : ['websocket', 'polling'];
137
+ }
138
+ processCorsOptions(cors) {
139
+ const corsConfig = cors || {};
140
+ if (!corsConfig.methods) {
141
+ corsConfig.methods = ['GET', 'POST'];
142
+ }
143
+ if (!corsConfig.origin) {
144
+ corsConfig.origin = [`https://${this.host}`, `http://${this.host}`];
145
+ }
146
+ return corsConfig;
147
+ }
148
+ initializeFastify() {
149
+ try {
150
+ return (0, fastify_1.default)({
151
+ logger: this.verbose === 'DEBUG',
152
+ ignoreTrailingSlash: true,
153
+ maxParamLength: 200,
154
+ caseSensitive: true,
155
+ });
156
+ }
157
+ catch (error) {
158
+ throw new IOServerError_1.IOServerError(`Unable to initialize server: ${error}`, 500);
159
+ }
160
+ }
161
+ setupPlugins(corsOptions) {
162
+ try {
163
+ // Register sensible plugin for HTTP shortcuts
164
+ this.webapp.register(sensible_1.default);
165
+ // Register CORS plugin with secure defaults
166
+ this.webapp.register(cors_1.default, {
167
+ ...corsOptions,
168
+ credentials: corsOptions?.credentials ?? false, // Default to false for security
169
+ optionsSuccessStatus: 204, // For CORS preflight requests
170
+ });
171
+ // Add 404 handler
172
+ this.webapp.setNotFoundHandler((request, reply) => {
173
+ reply.code(404).send({
174
+ statusCode: 404,
175
+ error: 'Not Found',
176
+ message: `Route ${request.method}:${request.url} not found`,
177
+ });
178
+ });
179
+ // Setup error handler
180
+ this.webapp.setErrorHandler((error, request, reply) => {
181
+ if (error instanceof IOServerError_1.IOServerError) {
182
+ reply.status(error.statusCode).send({
183
+ statusCode: error.statusCode,
184
+ error: error.name,
185
+ message: error.message,
186
+ });
187
+ }
188
+ else if (error.status) {
189
+ reply.status(error.status).send({
190
+ statusCode: error.status,
191
+ error: error.name || 'Error',
192
+ message: error.message,
193
+ });
194
+ }
195
+ else {
196
+ reply.status(500).send({
197
+ statusCode: 500,
198
+ error: 'Internal Server Error',
199
+ message: error.message,
200
+ });
201
+ }
202
+ });
203
+ }
204
+ catch (error) {
205
+ throw new IOServerError_1.IOServerError(`Unable to setup plugins: ${error}`, 500);
206
+ }
207
+ }
208
+ setupSocketIO(transportModes, cookieEnabled, corsOptions) {
209
+ try {
210
+ // Create Socket.IO server immediately, but it will attach when Fastify starts
211
+ this.webapp.ready().then(() => {
212
+ this.socketio = new socket_io_1.Server(this.webapp.server, {
213
+ transports: transportModes,
214
+ cookie: cookieEnabled,
215
+ cors: corsOptions,
216
+ });
217
+ // Add io property to webapp for compatibility
218
+ this.webapp.io = this.socketio;
219
+ this.log(6, '[*] Socket.IO server attached to HTTP server');
220
+ });
221
+ }
222
+ catch (error) {
223
+ throw new IOServerError_1.IOServerError(`Unable to setup Socket.IO: ${error}`, 500);
224
+ }
225
+ }
226
+ log(level, text) {
227
+ const currentLevel = IOServer.LOG_LEVELS.indexOf(this.verbose);
228
+ if (level <= currentLevel) {
229
+ if (level <= 4) {
230
+ console.error(text);
231
+ }
232
+ else {
233
+ console.log(text);
234
+ }
235
+ }
236
+ }
237
+ unique(array) {
238
+ return [...new Set(array)];
239
+ }
240
+ registerInternalClass(type, name, ClassConstructor) {
241
+ if (!name) {
242
+ throw new IOServerError_1.IOServerError('Name is mandatory', 400);
243
+ }
244
+ if (type !== 'service' && name.length < 2) {
245
+ throw new IOServerError_1.IOServerError('Name must be longer than 2 characters', 400);
246
+ }
247
+ if (IOServer.RESERVED_NAMES.includes(name)) {
248
+ throw new IOServerError_1.IOServerError('Sorry this is a reserved name', 400);
249
+ }
250
+ if (!ClassConstructor || !ClassConstructor.prototype) {
251
+ throw new IOServerError_1.IOServerError('Must be a constructor function', 400);
252
+ }
253
+ const listMap = this.getListMap(type);
254
+ if (listMap.has(name)) {
255
+ throw new IOServerError_1.IOServerError(`Sorry this ${type} already exists`, 409);
256
+ }
257
+ try {
258
+ this.log(7, `[*] Register ${type} ${name}`);
259
+ const instance = new ClassConstructor(this.appHandle);
260
+ listMap.set(name, instance);
261
+ }
262
+ catch (error) {
263
+ throw new IOServerError_1.IOServerError(`Error instantiating ${type}: ${error}`, 500);
264
+ }
265
+ }
266
+ getListMap(type) {
267
+ switch (type) {
268
+ case 'service':
269
+ return this.serviceLists;
270
+ case 'manager':
271
+ return this.managerLists;
272
+ case 'watcher':
273
+ return this.watcherLists;
274
+ case 'controller':
275
+ return this.controllerLists;
276
+ default:
277
+ throw new IOServerError_1.IOServerError(`Unknown type: ${type}`, 400);
278
+ }
279
+ }
280
+ dumpMethods(ClassConstructor) {
281
+ const result = [];
282
+ let prototype = ClassConstructor.prototype;
283
+ while (prototype && Object.getPrototypeOf(prototype)) {
284
+ const names = Object.getOwnPropertyNames(prototype);
285
+ result.push(...names);
286
+ prototype = Object.getPrototypeOf(prototype);
287
+ }
288
+ return this.unique(result).sort();
289
+ }
290
+ /**
291
+ * Registers a watcher component for background tasks
292
+ * @param {WatcherOptions} options - Watcher configuration options
293
+ * @throws {IOServerError} When watcher instantiation fails
294
+ */
295
+ addWatcher(options) {
296
+ try {
297
+ this.registerInternalClass('watcher', options.name, options.watcher);
298
+ }
299
+ catch (error) {
300
+ throw new IOServerError_1.IOServerError(`Error while instantiating ${options.name} watcher: ${error}`, 500);
301
+ }
302
+ }
303
+ /**
304
+ * Registers a manager component for shared functionality
305
+ * @param {ManagerOptions} options - Manager configuration options
306
+ * @throws {IOServerError} When manager instantiation fails
307
+ */
308
+ addManager(options) {
309
+ try {
310
+ this.registerInternalClass('manager', options.name, options.manager);
311
+ }
312
+ catch (error) {
313
+ throw new IOServerError_1.IOServerError(`Error while instantiating ${options.name} manager: ${error}`, 500);
314
+ }
315
+ }
316
+ /**
317
+ * Registers a service component for real-time WebSocket handling
318
+ * @param {ServiceOptions} options - Service configuration options
319
+ * @throws {IOServerError} When service instantiation fails
320
+ */
321
+ addService(options) {
322
+ const name = options.name || '/';
323
+ try {
324
+ this.registerInternalClass('service', name, options.service);
325
+ }
326
+ catch (error) {
327
+ throw new IOServerError_1.IOServerError(`Error while instantiating ${name} service: ${error}`, 500);
328
+ }
329
+ this.methodLists.set(name, this.dumpMethods(options.service));
330
+ this.middlewareLists.set(name, options.middlewares || []);
331
+ }
332
+ /**
333
+ * Registers a controller component for HTTP route handling
334
+ * @param {ControllerOptions} options - Controller configuration options
335
+ * @throws {IOServerError} When controller instantiation or route loading fails
336
+ */
337
+ addController(options) {
338
+ const middlewares = options.middlewares || [];
339
+ let prefix = options.prefix;
340
+ // Sanitize prefix
341
+ if (prefix) {
342
+ if (!prefix.startsWith('/')) {
343
+ prefix = `/${prefix}`;
344
+ }
345
+ if (prefix.endsWith('/')) {
346
+ prefix = prefix.slice(0, -1);
347
+ }
348
+ }
349
+ try {
350
+ this.registerInternalClass('controller', options.name, options.controller);
351
+ }
352
+ catch (error) {
353
+ throw new IOServerError_1.IOServerError(`Error while instantiating ${options.name} controller: ${error}`, 500);
354
+ }
355
+ const routeFile = path.join(this.routesPath, `${options.name}.json`);
356
+ if (!fs.existsSync(routeFile)) {
357
+ throw new IOServerError_1.IOServerError(`Routes file does not exist: ${routeFile}`, 404);
358
+ }
359
+ try {
360
+ const routes = JSON.parse(fs.readFileSync(routeFile, 'utf8'));
361
+ this.registerControllerRoutes(routes, options.name, prefix, middlewares);
362
+ }
363
+ catch (error) {
364
+ throw new IOServerError_1.IOServerError(`Error loading routes for ${options.name}: ${error}`, 500);
365
+ }
366
+ }
367
+ registerControllerRoutes(routes, controllerName, prefix, middlewares = []) {
368
+ const controller = this.controllerLists.get(controllerName);
369
+ routes.forEach(route => {
370
+ // Map controller methods to route handlers
371
+ const handlerOptions = [
372
+ 'onRequest',
373
+ 'preParsing',
374
+ 'preValidation',
375
+ 'preHandler',
376
+ 'preSerialization',
377
+ 'onSend',
378
+ 'onResponse',
379
+ 'handler',
380
+ 'errorHandler',
381
+ ];
382
+ handlerOptions.forEach(option => {
383
+ if (route[option] && controller[route[option]]) {
384
+ route[option] = controller[route[option]].bind(controller);
385
+ }
386
+ });
387
+ // Set URL with prefix logic:
388
+ // 1. If custom prefix is provided, use it
389
+ // 2. Otherwise, use controller name as prefix (unless it's root route)
390
+ if (prefix !== undefined) {
391
+ // Custom prefix provided (can be empty string for no prefix)
392
+ route.url = prefix + route.url;
393
+ }
394
+ else {
395
+ // Default behavior: use controller name as prefix unless route is "/"
396
+ if (route.url === '/' && controllerName !== 'root') {
397
+ // Keep root route as-is for main controllers
398
+ route.url = '/';
399
+ }
400
+ else {
401
+ route.url = `/${controllerName}${route.url}`;
402
+ }
403
+ }
404
+ // Setup middleware
405
+ if (!route.preValidation) {
406
+ route.preValidation = [];
407
+ }
408
+ middlewares.forEach(MiddlewareClass => {
409
+ const middleware = new MiddlewareClass();
410
+ if (middleware.handle) {
411
+ route.preValidation.push(middleware.handle(this.appHandle));
412
+ }
413
+ });
414
+ try {
415
+ this.log(7, `[*] Register controller route ${route.method} ${route.url}`);
416
+ this.webapp.route(route);
417
+ }
418
+ catch (error) {
419
+ this.log(3, `[!] Unable to register route: ${error}`);
420
+ }
421
+ });
422
+ }
423
+ /**
424
+ * Retrieves a registered service by name
425
+ * @param {string} name - The service name
426
+ * @returns {any} The service instance or undefined if not found
427
+ */
428
+ getService(name) {
429
+ return this.serviceLists.get(name);
430
+ }
431
+ /**
432
+ * Starts the IOServer instance
433
+ * Initializes Socket.IO, starts watchers, and begins listening for connections
434
+ * @returns {Promise<void>} Promise that resolves when server is started
435
+ * @throws {IOServerError} When server startup fails
436
+ */
437
+ async start() {
438
+ const now = new Date();
439
+ const timestamp = now.toISOString();
440
+ this.log(4, `################### IOServer v${IOServer.VERSION} ###################`);
441
+ this.log(5, `################### ${timestamp} ###################`);
442
+ // Register managers in appHandle
443
+ this.managerLists.forEach((manager, name) => {
444
+ this.log(6, `[*] Register ${name} manager`);
445
+ this.appHandle[name] = manager;
446
+ });
447
+ // Ensure Fastify is ready and Socket.IO is initialized
448
+ await this.webapp.ready();
449
+ // Wait for Socket.IO to be properly initialized
450
+ let retries = 0;
451
+ const maxRetries = 10;
452
+ while (!this.socketio && retries < maxRetries) {
453
+ await (0, promises_1.setTimeout)(100);
454
+ retries++;
455
+ }
456
+ if (!this.socketio) {
457
+ throw new IOServerError_1.IOServerError('Socket.IO server failed to initialize', 500);
458
+ }
459
+ this.log(6, '[*] Socket.IO server ready');
460
+ // Setup Socket.IO namespaces and services
461
+ this.serviceLists.forEach((service, serviceName) => {
462
+ const namespace = serviceName === '/'
463
+ ? this.socketio.of('/')
464
+ : this.socketio.of(`/${serviceName}`);
465
+ // Register middleware for namespace
466
+ const middlewares = this.middlewareLists.get(serviceName) || [];
467
+ middlewares.forEach(MiddlewareClass => {
468
+ const middleware = new MiddlewareClass();
469
+ if (middleware.handle) {
470
+ namespace.use(middleware.handle(this.appHandle));
471
+ }
472
+ });
473
+ // Setup connection handler
474
+ namespace.on('connection', this.handleConnection(serviceName));
475
+ this.log(6, `[*] Service ${serviceName} registered...`);
476
+ });
477
+ // Start watchers
478
+ try {
479
+ const watcherPromises = Array.from(this.watcherLists.values()).map(async (watcher) => {
480
+ try {
481
+ this.log(6, `[*] Start watcher ${watcher.constructor.name}`);
482
+ if (watcher.watch) {
483
+ await watcher.watch();
484
+ }
485
+ }
486
+ catch (error) {
487
+ throw new IOServerError_1.IOServerError(`Unable to start ${watcher.constructor.name} watcher: ${error}`, 500);
488
+ }
489
+ });
490
+ // Don't wait for watchers to complete
491
+ Promise.all(watcherPromises).catch(error => {
492
+ this.log(3, `[!] Error starting watchers: ${error}`);
493
+ });
494
+ }
495
+ catch (error) {
496
+ throw new IOServerError_1.IOServerError(`Error starting watchers: ${error}`, 500);
497
+ }
498
+ // Start web server
499
+ try {
500
+ this.log(5, `[*] Starting server on http://${this.host}:${this.port} ...`);
501
+ await this.webapp.listen({ port: this.port, host: this.host });
502
+ this.log(5, `[*] Server listening on http://${this.host}:${this.port}`);
503
+ }
504
+ catch (error) {
505
+ this.log(3, `[!] Unable to start server: ${error}`);
506
+ throw new IOServerError_1.IOServerError(`Unable to start server: ${error}`, 500);
507
+ }
508
+ }
509
+ /**
510
+ * Gets the server hostname
511
+ * @returns {string} The server hostname
512
+ */
513
+ getHost() {
514
+ return this.host;
515
+ }
516
+ /**
517
+ * Gets the server port number
518
+ * @returns {number} The server port
519
+ */
520
+ getPort() {
521
+ return this.port;
522
+ }
523
+ /**
524
+ * Gets the Fastify instance
525
+ * @returns {FastifyInstance} The Fastify application instance
526
+ */
527
+ getApp() {
528
+ return this.webapp;
529
+ }
530
+ /**
531
+ * Stops the IOServer instance
532
+ * @returns {Promise<void>} Promise that resolves when server is stopped
533
+ * @throws {IOServerError} When server shutdown fails
534
+ */
535
+ async stop() {
536
+ try {
537
+ await this.webapp.close();
538
+ this.log(6, '[*] Server stopped');
539
+ }
540
+ catch (error) {
541
+ throw new IOServerError_1.IOServerError(`Unable to stop server: ${error}`, 500);
542
+ }
543
+ }
544
+ /**
545
+ * Sends real-time messages to connected clients
546
+ * @param {SendToOptions} options - Options for message delivery
547
+ * @returns {boolean} True if message was sent successfully, false otherwise
548
+ */
549
+ sendTo(options) {
550
+ if (!this.socketio) {
551
+ this.log(3, '[!] Socket.IO not initialized, cannot send message');
552
+ return false;
553
+ }
554
+ let namespace = options.namespace;
555
+ if (namespace) {
556
+ if (!namespace.startsWith('/')) {
557
+ namespace = `/${namespace}`;
558
+ }
559
+ }
560
+ else {
561
+ namespace = '/';
562
+ }
563
+ const ns = this.socketio.of(namespace);
564
+ if (options.sid) {
565
+ const socket = ns.sockets.get(options.sid);
566
+ if (socket) {
567
+ socket.emit(options.event, options.data);
568
+ }
569
+ }
570
+ else {
571
+ const target = options.room ? ns.in(options.room) : ns;
572
+ target.emit(options.event, options.data);
573
+ }
574
+ return true;
575
+ }
576
+ /**
577
+ * Handles new WebSocket connections for a specific service
578
+ * @private
579
+ * @param {string} serviceName - The name of the service
580
+ * @returns {Function} Connection handler function
581
+ */
582
+ handleConnection(serviceName) {
583
+ return (socket) => {
584
+ this.log(5, `[*] Received connection for service ${serviceName}`);
585
+ const methods = this.methodLists.get(serviceName) || [];
586
+ this.serviceLists.get(serviceName);
587
+ methods.forEach(method => {
588
+ // Skip private methods and constructor
589
+ if (method.startsWith('_') || method === 'constructor') {
590
+ return;
591
+ }
592
+ this.log(6, `[*] Method ${method} of ${serviceName} listening...`);
593
+ socket.on(method, this.handleCallback(serviceName, method, socket));
594
+ });
595
+ };
596
+ }
597
+ /**
598
+ * Creates a callback handler for WebSocket method calls
599
+ * @private
600
+ * @param {string} serviceName - The name of the service
601
+ * @param {string} methodName - The name of the method
602
+ * @param {any} socket - The Socket.IO socket instance
603
+ * @returns {Function} Callback handler function
604
+ */
605
+ handleCallback(serviceName, methodName, socket) {
606
+ return async (data, callback) => {
607
+ this.log(6, `[*] Call method ${methodName} of service ${serviceName}`);
608
+ try {
609
+ const service = this.serviceLists.get(serviceName);
610
+ if (service && service[methodName]) {
611
+ await service[methodName](socket, data, callback);
612
+ }
613
+ }
614
+ catch (error) {
615
+ let ioError = error;
616
+ if (typeof error === 'string') {
617
+ ioError = new IOServerError_1.IOServerError(error, 500);
618
+ }
619
+ const payload = {
620
+ status: 'error',
621
+ type: ioError?.constructor?.name || 'Error',
622
+ message: ioError?.message || null,
623
+ statusCode: ioError?.statusCode || 500,
624
+ };
625
+ this.log(5, `Error on ${serviceName}:${methodName} execution: ${error}`);
626
+ if (callback) {
627
+ callback(payload);
628
+ }
629
+ else {
630
+ socket.emit('error', payload);
631
+ }
632
+ }
633
+ };
634
+ }
635
+ }
636
+ exports.IOServer = IOServer;
637
+ IOServer.VERSION = '2.0.0';
638
+ IOServer.DEFAULT_PORT = 8080;
639
+ IOServer.DEFAULT_HOST = 'localhost';
640
+ IOServer.LOG_LEVELS = [
641
+ 'EMERGENCY',
642
+ 'ALERT',
643
+ 'CRITICAL',
644
+ 'ERROR',
645
+ 'WARNING',
646
+ 'NOTIFICATION',
647
+ 'INFORMATION',
648
+ 'DEBUG',
649
+ ];
650
+ IOServer.TRANSPORTS = [
651
+ 'websocket',
652
+ 'polling',
653
+ ];
654
+ IOServer.RESERVED_NAMES = ['send', 'log', 'verbose'];
655
+ exports.default = IOServer;
656
+ //# sourceMappingURL=IOServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IOServer.js","sourceRoot":"","sources":["../src/IOServer.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAC7B,8CAA6C;AAC7C,sDAKiB;AACjB,yCAAqD;AACrD,yDAAiC;AACjC,iEAAyC;AACzC,mDAAgD;AAkIhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAa,QAAQ;IAmCnB;;;OAGG;IACH,YAAY,UAA2B,EAAE;QAXxB,iBAAY,GAAqB,IAAI,GAAG,EAAE,CAAC;QAC3C,iBAAY,GAAqB,IAAI,GAAG,EAAE,CAAC;QAC3C,gBAAW,GAA0B,IAAI,GAAG,EAAE,CAAC;QAC/C,iBAAY,GAAqB,IAAI,GAAG,EAAE,CAAC;QAC3C,oBAAe,GAAqB,IAAI,GAAG,EAAE,CAA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