@rapidrest/service-core 1.0.0-beta.1 → 1.0.0-beta.2

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.
Files changed (157) hide show
  1. package/dist/lib/auth/AuthMiddleware.js +33 -3
  2. package/dist/lib/auth/AuthMiddleware.js.map +1 -1
  3. package/dist/lib/auth/BasicStrategy.js +46 -39
  4. package/dist/lib/auth/BasicStrategy.js.map +1 -1
  5. package/dist/lib/auth/JWTStrategy.js +69 -60
  6. package/dist/lib/auth/JWTStrategy.js.map +1 -1
  7. package/dist/lib/index.js +2 -1
  8. package/dist/lib/index.js.map +1 -1
  9. package/dist/lib/routes/RouteUtils.js +8 -7
  10. package/dist/lib/routes/RouteUtils.js.map +1 -1
  11. package/dist/types/auth/AuthMiddleware.d.ts +12 -1
  12. package/dist/types/auth/AuthStrategy.d.ts +13 -1
  13. package/dist/types/auth/BasicStrategy.d.ts +7 -3
  14. package/dist/types/auth/JWTStrategy.d.ts +6 -3
  15. package/dist/types/index.d.ts +2 -1
  16. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/MongoRepository.md +1 -1
  17. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/RedisConnection.md +1 -1
  18. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/Repository.md +1 -1
  19. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Default.md +1 -1
  20. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Description.md +1 -1
  21. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Document.md +1 -1
  22. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Example.md +1 -1
  23. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Format.md +1 -1
  24. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Returns.md +1 -1
  25. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Summary.md +1 -1
  26. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Tags.md +1 -1
  27. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/TypeInfo.md +1 -1
  28. package/docs/reference/@rapidrest/namespaces/DocDecorators/interfaces/DocumentsData.md +7 -7
  29. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/EventListener.md +1 -1
  30. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/OnEvent.md +1 -1
  31. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Cache.md +1 -1
  32. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/ChildEntity.md +1 -1
  33. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/DataStore.md +1 -1
  34. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Identifier.md +1 -1
  35. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Protect.md +1 -1
  36. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Reference.md +1 -1
  37. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Shard.md +1 -1
  38. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/TrackChanges.md +1 -1
  39. package/docs/reference/@rapidrest/namespaces/ModelDecorators/interfaces/PendingTypeOrmColumn.md +5 -5
  40. package/docs/reference/@rapidrest/namespaces/ModelDecorators/variables/pendingTypeOrmColumns.md +1 -1
  41. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Column.md +1 -1
  42. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Entity.md +1 -1
  43. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Index.md +3 -3
  44. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/PrimaryColumn.md +1 -1
  45. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Unique.md +3 -3
  46. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getColumnMetadata.md +1 -1
  47. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getEntityName.md +1 -1
  48. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getIndexMetadata.md +1 -1
  49. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnInfo.md +4 -4
  50. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnOptions.md +5 -5
  51. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexInfo.md +4 -4
  52. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexOptions.md +5 -5
  53. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/After.md +1 -1
  54. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Auth.md +1 -1
  55. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/AuthResult.md +1 -1
  56. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Before.md +1 -1
  57. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/ContentType.md +1 -1
  58. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Delete.md +1 -1
  59. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Get.md +1 -1
  60. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Head.md +1 -1
  61. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Header.md +1 -1
  62. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Method.md +1 -1
  63. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Model.md +1 -1
  64. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Options.md +1 -1
  65. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Param.md +1 -1
  66. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Patch.md +1 -1
  67. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Post.md +1 -1
  68. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Protect.md +1 -1
  69. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Put.md +1 -1
  70. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Query.md +1 -1
  71. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Request.md +1 -1
  72. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/RequiresRole.md +1 -1
  73. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Response.md +1 -1
  74. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Route.md +1 -1
  75. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Socket.md +1 -1
  76. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/User.md +1 -1
  77. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Validate.md +1 -1
  78. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/WebSocket.md +1 -1
  79. package/docs/reference/classes/ACLUtils.md +10 -10
  80. package/docs/reference/classes/AdminRoute.md +3 -3
  81. package/docs/reference/classes/AuthMiddleware.md +55 -13
  82. package/docs/reference/classes/BackgroundService.md +8 -8
  83. package/docs/reference/classes/BackgroundServiceManager.md +7 -7
  84. package/docs/reference/classes/BaseEntity.md +6 -6
  85. package/docs/reference/classes/BaseMongoEntity.md +7 -7
  86. package/docs/reference/classes/BasicStrategy.md +52 -10
  87. package/docs/reference/classes/BasicStrategyOptions.md +35 -11
  88. package/docs/reference/classes/BulkError.md +3 -3
  89. package/docs/reference/classes/ConnectionManager.md +4 -4
  90. package/docs/reference/classes/EventListenerManager.md +5 -5
  91. package/docs/reference/classes/HttpRouter.md +343 -0
  92. package/docs/reference/classes/JWTStrategy.md +37 -14
  93. package/docs/reference/classes/JWTStrategyOptions.md +10 -10
  94. package/docs/reference/classes/MetricsRoute.md +2 -2
  95. package/docs/reference/classes/ModelRoute.md +28 -28
  96. package/docs/reference/classes/ModelUtils.md +10 -10
  97. package/docs/reference/classes/MongoConnection.md +12 -12
  98. package/docs/reference/classes/MongoRepository.md +17 -17
  99. package/docs/reference/classes/MongoSchemaSync.md +3 -3
  100. package/docs/reference/classes/NetUtils.md +4 -4
  101. package/docs/reference/classes/NotificationUtils.md +3 -3
  102. package/docs/reference/classes/ObjectFactory.md +10 -10
  103. package/docs/reference/classes/OpenAPIRoute.md +5 -5
  104. package/docs/reference/classes/OpenApiSpec.md +45 -45
  105. package/docs/reference/classes/RecoverableBaseEntity.md +7 -7
  106. package/docs/reference/classes/RecoverableBaseMongoEntity.md +8 -8
  107. package/docs/reference/classes/RedisTransport.md +4 -4
  108. package/docs/reference/classes/RepoUtils.md +28 -28
  109. package/docs/reference/classes/RouteUtils.md +17 -17
  110. package/docs/reference/classes/Server.md +29 -29
  111. package/docs/reference/classes/SimpleEntity.md +3 -3
  112. package/docs/reference/classes/SimpleMongoEntity.md +4 -4
  113. package/docs/reference/classes/StatusExtraData.md +4 -4
  114. package/docs/reference/classes/StatusRoute.md +1 -1
  115. package/docs/reference/classes/UWSRequest.md +226 -0
  116. package/docs/reference/classes/UWSResponse.md +257 -0
  117. package/docs/reference/classes/UWSWebSocketShim.md +958 -0
  118. package/docs/reference/enumerations/ACLAction.md +7 -7
  119. package/docs/reference/enumerations/ApiErrorMessages.md +15 -15
  120. package/docs/reference/enumerations/ApiErrors.md +15 -15
  121. package/docs/reference/functions/createWebSocketStream.md +27 -0
  122. package/docs/reference/functions/isSqlDataSource.md +1 -1
  123. package/docs/reference/functions/readBody.md +29 -0
  124. package/docs/reference/functions/resolveCollectionName.md +1 -1
  125. package/docs/reference/functions/runChain.md +40 -0
  126. package/docs/reference/functions/snakeCase.md +1 -1
  127. package/docs/reference/globals.md +15 -0
  128. package/docs/reference/interfaces/ACLRecord.md +8 -8
  129. package/docs/reference/interfaces/AccessControlList.md +5 -5
  130. package/docs/reference/interfaces/AuthResult.md +5 -5
  131. package/docs/reference/interfaces/AuthStrategy.md +47 -9
  132. package/docs/reference/interfaces/CreateRequestOptions.md +11 -11
  133. package/docs/reference/interfaces/DeleteRequestOptions.md +13 -13
  134. package/docs/reference/interfaces/FindRequestOptions.md +12 -12
  135. package/docs/reference/interfaces/HttpRequest.md +147 -0
  136. package/docs/reference/interfaces/HttpResponse.md +164 -0
  137. package/docs/reference/interfaces/JWTAuthResult.md +9 -9
  138. package/docs/reference/interfaces/RepoCreateOptions.md +7 -7
  139. package/docs/reference/interfaces/RepoDeleteOptions.md +9 -9
  140. package/docs/reference/interfaces/RepoFindOptions.md +11 -11
  141. package/docs/reference/interfaces/RepoOperationOptions.md +6 -6
  142. package/docs/reference/interfaces/RepoUpdateOptions.md +8 -8
  143. package/docs/reference/interfaces/RequestOptions.md +10 -10
  144. package/docs/reference/interfaces/RequestWS.md +225 -0
  145. package/docs/reference/interfaces/TruncateRequestOptions.md +15 -15
  146. package/docs/reference/interfaces/UpdateRequestOptions.md +13 -13
  147. package/docs/reference/type-aliases/ErrorHandler.md +35 -0
  148. package/docs/reference/type-aliases/NextFunction.md +23 -0
  149. package/docs/reference/type-aliases/OneOrMany.md +1 -1
  150. package/docs/reference/type-aliases/OneOrNull.md +1 -1
  151. package/docs/reference/type-aliases/PartialBaseEntity.md +1 -1
  152. package/docs/reference/type-aliases/PartialSimpleEntity.md +1 -1
  153. package/docs/reference/type-aliases/RequestHandler.md +31 -0
  154. package/docs/reference/type-aliases/UpdateObject.md +1 -1
  155. package/docs/reference/type-aliases/WsUpgradeAuth.md +27 -0
  156. package/docs/reference/type-aliases/WsUpgradeAuthResult.md +47 -0
  157. package/package.json +2 -2
@@ -0,0 +1,958 @@
1
+ [**@rapidrest/service-core**](../README.md)
2
+
3
+ ***
4
+
5
+ [@rapidrest/service-core](../globals.md) / UWSWebSocketShim
6
+
7
+ # Class: UWSWebSocketShim
8
+
9
+ Defined in: [src/http/WebSocket.ts:40](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/WebSocket.ts#L40)
10
+
11
+ Wraps a uWS `WebSocket` handle and exposes an EventEmitter-based API compatible
12
+ with what route handlers (e.g. `AdminRoute`) expect.
13
+
14
+ uWS WebSockets fire events via behavior callbacks on the route, not on the socket
15
+ object itself. This shim bridges that gap by:
16
+ - Forwarding `message` / `close` events from the route behavior to this emitter.
17
+ - Exposing `send(data, cb?)` and `close(code?, reason?)` that delegate to uWS.
18
+
19
+ The Router's `ws()` implementation stores the shim in `ws.getUserData()` so that
20
+ behavior callbacks can call `shim.emit(...)`.
21
+
22
+ ## Extends
23
+
24
+ - `EventEmitter`
25
+
26
+ ## Constructors
27
+
28
+ ### Constructor
29
+
30
+ > **new UWSWebSocketShim**(`ws`): `UWSWebSocketShim`
31
+
32
+ Defined in: [src/http/WebSocket.ts:44](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/WebSocket.ts#L44)
33
+
34
+ #### Parameters
35
+
36
+ ##### ws
37
+
38
+ `WebSocket`\<`any`\>
39
+
40
+ #### Returns
41
+
42
+ `UWSWebSocketShim`
43
+
44
+ #### Overrides
45
+
46
+ `EventEmitter.constructor`
47
+
48
+ ## Properties
49
+
50
+ ### readyState
51
+
52
+ > **readyState**: `number` = `1`
53
+
54
+ Defined in: [src/http/WebSocket.ts:42](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/WebSocket.ts#L42)
55
+
56
+ ## Methods
57
+
58
+ ### \[captureRejectionSymbol\]()?
59
+
60
+ > `optional` **\[captureRejectionSymbol\]**(`error`, `event`, ...`args`): `void`
61
+
62
+ Defined in: node\_modules/@types/node/events.d.ts:87
63
+
64
+ The `Symbol.for('nodejs.rejection')` method is called in case a
65
+ promise rejection happens when emitting an event and
66
+ `captureRejections` is enabled on the emitter.
67
+ It is possible to use `events.captureRejectionSymbol` in
68
+ place of `Symbol.for('nodejs.rejection')`.
69
+
70
+ ```js
71
+ import { EventEmitter, captureRejectionSymbol } from 'node:events';
72
+
73
+ class MyClass extends EventEmitter {
74
+ constructor() {
75
+ super({ captureRejections: true });
76
+ }
77
+
78
+ [captureRejectionSymbol](err, event, ...args) {
79
+ console.log('rejection happened for', event, 'with', err, ...args);
80
+ this.destroy(err);
81
+ }
82
+
83
+ destroy(err) {
84
+ // Tear the resource down here.
85
+ }
86
+ }
87
+ ```
88
+
89
+ #### Parameters
90
+
91
+ ##### error
92
+
93
+ `Error`
94
+
95
+ ##### event
96
+
97
+ `string` \| `symbol`
98
+
99
+ ##### args
100
+
101
+ ...`any`[]
102
+
103
+ #### Returns
104
+
105
+ `void`
106
+
107
+ #### Since
108
+
109
+ v13.4.0, v12.16.0
110
+
111
+ #### Inherited from
112
+
113
+ `EventEmitter.[captureRejectionSymbol]`
114
+
115
+ ***
116
+
117
+ ### addListener()
118
+
119
+ > **addListener**\<`E`\>(`eventName`, `listener`): `this`
120
+
121
+ Defined in: node\_modules/@types/node/events.d.ts:92
122
+
123
+ Alias for `emitter.on(eventName, listener)`.
124
+
125
+ #### Type Parameters
126
+
127
+ ##### E
128
+
129
+ `E` *extends* `string` \| `symbol`
130
+
131
+ #### Parameters
132
+
133
+ ##### eventName
134
+
135
+ `string` \| `symbol`
136
+
137
+ ##### listener
138
+
139
+ (...`args`) => `void`
140
+
141
+ #### Returns
142
+
143
+ `this`
144
+
145
+ #### Since
146
+
147
+ v0.1.26
148
+
149
+ #### Inherited from
150
+
151
+ `EventEmitter.addListener`
152
+
153
+ ***
154
+
155
+ ### close()
156
+
157
+ > **close**(`code?`, `reason?`): `void`
158
+
159
+ Defined in: [src/http/WebSocket.ts:69](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/WebSocket.ts#L69)
160
+
161
+ Closes the WebSocket connection with an optional code and reason.
162
+
163
+ #### Parameters
164
+
165
+ ##### code?
166
+
167
+ `number`
168
+
169
+ ##### reason?
170
+
171
+ `string`
172
+
173
+ #### Returns
174
+
175
+ `void`
176
+
177
+ ***
178
+
179
+ ### emit()
180
+
181
+ > **emit**\<`E`\>(`eventName`, ...`args`): `boolean`
182
+
183
+ Defined in: node\_modules/@types/node/events.d.ts:134
184
+
185
+ Synchronously calls each of the listeners registered for the event named
186
+ `eventName`, in the order they were registered, passing the supplied arguments
187
+ to each.
188
+
189
+ Returns `true` if the event had listeners, `false` otherwise.
190
+
191
+ ```js
192
+ import { EventEmitter } from 'node:events';
193
+ const myEmitter = new EventEmitter();
194
+
195
+ // First listener
196
+ myEmitter.on('event', function firstListener() {
197
+ console.log('Helloooo! first listener');
198
+ });
199
+ // Second listener
200
+ myEmitter.on('event', function secondListener(arg1, arg2) {
201
+ console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
202
+ });
203
+ // Third listener
204
+ myEmitter.on('event', function thirdListener(...args) {
205
+ const parameters = args.join(', ');
206
+ console.log(`event with parameters ${parameters} in third listener`);
207
+ });
208
+
209
+ console.log(myEmitter.listeners('event'));
210
+
211
+ myEmitter.emit('event', 1, 2, 3, 4, 5);
212
+
213
+ // Prints:
214
+ // [
215
+ // [Function: firstListener],
216
+ // [Function: secondListener],
217
+ // [Function: thirdListener]
218
+ // ]
219
+ // Helloooo! first listener
220
+ // event with parameters 1, 2 in second listener
221
+ // event with parameters 1, 2, 3, 4, 5 in third listener
222
+ ```
223
+
224
+ #### Type Parameters
225
+
226
+ ##### E
227
+
228
+ `E` *extends* `string` \| `symbol`
229
+
230
+ #### Parameters
231
+
232
+ ##### eventName
233
+
234
+ `string` \| `symbol`
235
+
236
+ ##### args
237
+
238
+ ...`any`[]
239
+
240
+ #### Returns
241
+
242
+ `boolean`
243
+
244
+ #### Since
245
+
246
+ v0.1.26
247
+
248
+ #### Inherited from
249
+
250
+ `EventEmitter.emit`
251
+
252
+ ***
253
+
254
+ ### eventNames()
255
+
256
+ > **eventNames**(): (`string` \| `symbol`)[]
257
+
258
+ Defined in: node\_modules/@types/node/events.d.ts:154
259
+
260
+ Returns an array listing the events for which the emitter has registered
261
+ listeners.
262
+
263
+ ```js
264
+ import { EventEmitter } from 'node:events';
265
+
266
+ const myEE = new EventEmitter();
267
+ myEE.on('foo', () => {});
268
+ myEE.on('bar', () => {});
269
+
270
+ const sym = Symbol('symbol');
271
+ myEE.on(sym, () => {});
272
+
273
+ console.log(myEE.eventNames());
274
+ // Prints: [ 'foo', 'bar', Symbol(symbol) ]
275
+ ```
276
+
277
+ #### Returns
278
+
279
+ (`string` \| `symbol`)[]
280
+
281
+ #### Since
282
+
283
+ v6.0.0
284
+
285
+ #### Inherited from
286
+
287
+ `EventEmitter.eventNames`
288
+
289
+ ***
290
+
291
+ ### getMaxListeners()
292
+
293
+ > **getMaxListeners**(): `number`
294
+
295
+ Defined in: node\_modules/@types/node/events.d.ts:161
296
+
297
+ Returns the current max listener value for the `EventEmitter` which is either
298
+ set by `emitter.setMaxListeners(n)` or defaults to
299
+ `events.defaultMaxListeners`.
300
+
301
+ #### Returns
302
+
303
+ `number`
304
+
305
+ #### Since
306
+
307
+ v1.0.0
308
+
309
+ #### Inherited from
310
+
311
+ `EventEmitter.getMaxListeners`
312
+
313
+ ***
314
+
315
+ ### listenerCount()
316
+
317
+ > **listenerCount**\<`E`\>(`eventName`, `listener?`): `number`
318
+
319
+ Defined in: node\_modules/@types/node/events.d.ts:170
320
+
321
+ Returns the number of listeners listening for the event named `eventName`.
322
+ If `listener` is provided, it will return how many times the listener is found
323
+ in the list of the listeners of the event.
324
+
325
+ #### Type Parameters
326
+
327
+ ##### E
328
+
329
+ `E` *extends* `string` \| `symbol`
330
+
331
+ #### Parameters
332
+
333
+ ##### eventName
334
+
335
+ `string` \| `symbol`
336
+
337
+ The name of the event being listened for
338
+
339
+ ##### listener?
340
+
341
+ (...`args`) => `void`
342
+
343
+ The event handler function
344
+
345
+ #### Returns
346
+
347
+ `number`
348
+
349
+ #### Since
350
+
351
+ v3.2.0
352
+
353
+ #### Inherited from
354
+
355
+ `EventEmitter.listenerCount`
356
+
357
+ ***
358
+
359
+ ### listeners()
360
+
361
+ > **listeners**\<`E`\>(`eventName`): (...`args`) => `void`[]
362
+
363
+ Defined in: node\_modules/@types/node/events.d.ts:186
364
+
365
+ Returns a copy of the array of listeners for the event named `eventName`.
366
+
367
+ ```js
368
+ server.on('connection', (stream) => {
369
+ console.log('someone connected!');
370
+ });
371
+ console.log(util.inspect(server.listeners('connection')));
372
+ // Prints: [ [Function] ]
373
+ ```
374
+
375
+ #### Type Parameters
376
+
377
+ ##### E
378
+
379
+ `E` *extends* `string` \| `symbol`
380
+
381
+ #### Parameters
382
+
383
+ ##### eventName
384
+
385
+ `string` \| `symbol`
386
+
387
+ #### Returns
388
+
389
+ (...`args`) => `void`[]
390
+
391
+ #### Since
392
+
393
+ v0.1.26
394
+
395
+ #### Inherited from
396
+
397
+ `EventEmitter.listeners`
398
+
399
+ ***
400
+
401
+ ### off()
402
+
403
+ > **off**\<`E`\>(`eventName`, `listener`): `this`
404
+
405
+ Defined in: node\_modules/@types/node/events.d.ts:191
406
+
407
+ Alias for `emitter.removeListener()`.
408
+
409
+ #### Type Parameters
410
+
411
+ ##### E
412
+
413
+ `E` *extends* `string` \| `symbol`
414
+
415
+ #### Parameters
416
+
417
+ ##### eventName
418
+
419
+ `string` \| `symbol`
420
+
421
+ ##### listener
422
+
423
+ (...`args`) => `void`
424
+
425
+ #### Returns
426
+
427
+ `this`
428
+
429
+ #### Since
430
+
431
+ v10.0.0
432
+
433
+ #### Inherited from
434
+
435
+ `EventEmitter.off`
436
+
437
+ ***
438
+
439
+ ### on()
440
+
441
+ > **on**\<`E`\>(`eventName`, `listener`): `this`
442
+
443
+ Defined in: node\_modules/@types/node/events.d.ts:225
444
+
445
+ Adds the `listener` function to the end of the listeners array for the
446
+ event named `eventName`. No checks are made to see if the `listener` has
447
+ already been added. Multiple calls passing the same combination of `eventName`
448
+ and `listener` will result in the `listener` being added, and called, multiple
449
+ times.
450
+
451
+ ```js
452
+ server.on('connection', (stream) => {
453
+ console.log('someone connected!');
454
+ });
455
+ ```
456
+
457
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
458
+
459
+ By default, event listeners are invoked in the order they are added. The
460
+ `emitter.prependListener()` method can be used as an alternative to add the
461
+ event listener to the beginning of the listeners array.
462
+
463
+ ```js
464
+ import { EventEmitter } from 'node:events';
465
+ const myEE = new EventEmitter();
466
+ myEE.on('foo', () => console.log('a'));
467
+ myEE.prependListener('foo', () => console.log('b'));
468
+ myEE.emit('foo');
469
+ // Prints:
470
+ // b
471
+ // a
472
+ ```
473
+
474
+ #### Type Parameters
475
+
476
+ ##### E
477
+
478
+ `E` *extends* `string` \| `symbol`
479
+
480
+ #### Parameters
481
+
482
+ ##### eventName
483
+
484
+ `string` \| `symbol`
485
+
486
+ The name of the event.
487
+
488
+ ##### listener
489
+
490
+ (...`args`) => `void`
491
+
492
+ The callback function
493
+
494
+ #### Returns
495
+
496
+ `this`
497
+
498
+ #### Since
499
+
500
+ v0.1.101
501
+
502
+ #### Inherited from
503
+
504
+ `EventEmitter.on`
505
+
506
+ ***
507
+
508
+ ### once()
509
+
510
+ > **once**\<`E`\>(`eventName`, `listener`): `this`
511
+
512
+ Defined in: node\_modules/@types/node/events.d.ts:256
513
+
514
+ Adds a **one-time** `listener` function for the event named `eventName`. The
515
+ next time `eventName` is triggered, this listener is removed and then invoked.
516
+
517
+ ```js
518
+ server.once('connection', (stream) => {
519
+ console.log('Ah, we have our first user!');
520
+ });
521
+ ```
522
+
523
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
524
+
525
+ By default, event listeners are invoked in the order they are added. The
526
+ `emitter.prependOnceListener()` method can be used as an alternative to add the
527
+ event listener to the beginning of the listeners array.
528
+
529
+ ```js
530
+ import { EventEmitter } from 'node:events';
531
+ const myEE = new EventEmitter();
532
+ myEE.once('foo', () => console.log('a'));
533
+ myEE.prependOnceListener('foo', () => console.log('b'));
534
+ myEE.emit('foo');
535
+ // Prints:
536
+ // b
537
+ // a
538
+ ```
539
+
540
+ #### Type Parameters
541
+
542
+ ##### E
543
+
544
+ `E` *extends* `string` \| `symbol`
545
+
546
+ #### Parameters
547
+
548
+ ##### eventName
549
+
550
+ `string` \| `symbol`
551
+
552
+ The name of the event.
553
+
554
+ ##### listener
555
+
556
+ (...`args`) => `void`
557
+
558
+ The callback function
559
+
560
+ #### Returns
561
+
562
+ `this`
563
+
564
+ #### Since
565
+
566
+ v0.3.0
567
+
568
+ #### Inherited from
569
+
570
+ `EventEmitter.once`
571
+
572
+ ***
573
+
574
+ ### prependListener()
575
+
576
+ > **prependListener**\<`E`\>(`eventName`, `listener`): `this`
577
+
578
+ Defined in: node\_modules/@types/node/events.d.ts:275
579
+
580
+ Adds the `listener` function to the _beginning_ of the listeners array for the
581
+ event named `eventName`. No checks are made to see if the `listener` has
582
+ already been added. Multiple calls passing the same combination of `eventName`
583
+ and `listener` will result in the `listener` being added, and called, multiple
584
+ times.
585
+
586
+ ```js
587
+ server.prependListener('connection', (stream) => {
588
+ console.log('someone connected!');
589
+ });
590
+ ```
591
+
592
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
593
+
594
+ #### Type Parameters
595
+
596
+ ##### E
597
+
598
+ `E` *extends* `string` \| `symbol`
599
+
600
+ #### Parameters
601
+
602
+ ##### eventName
603
+
604
+ `string` \| `symbol`
605
+
606
+ The name of the event.
607
+
608
+ ##### listener
609
+
610
+ (...`args`) => `void`
611
+
612
+ The callback function
613
+
614
+ #### Returns
615
+
616
+ `this`
617
+
618
+ #### Since
619
+
620
+ v6.0.0
621
+
622
+ #### Inherited from
623
+
624
+ `EventEmitter.prependListener`
625
+
626
+ ***
627
+
628
+ ### prependOnceListener()
629
+
630
+ > **prependOnceListener**\<`E`\>(`eventName`, `listener`): `this`
631
+
632
+ Defined in: node\_modules/@types/node/events.d.ts:292
633
+
634
+ Adds a **one-time** `listener` function for the event named `eventName` to the
635
+ _beginning_ of the listeners array. The next time `eventName` is triggered, this
636
+ listener is removed, and then invoked.
637
+
638
+ ```js
639
+ server.prependOnceListener('connection', (stream) => {
640
+ console.log('Ah, we have our first user!');
641
+ });
642
+ ```
643
+
644
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
645
+
646
+ #### Type Parameters
647
+
648
+ ##### E
649
+
650
+ `E` *extends* `string` \| `symbol`
651
+
652
+ #### Parameters
653
+
654
+ ##### eventName
655
+
656
+ `string` \| `symbol`
657
+
658
+ The name of the event.
659
+
660
+ ##### listener
661
+
662
+ (...`args`) => `void`
663
+
664
+ The callback function
665
+
666
+ #### Returns
667
+
668
+ `this`
669
+
670
+ #### Since
671
+
672
+ v6.0.0
673
+
674
+ #### Inherited from
675
+
676
+ `EventEmitter.prependOnceListener`
677
+
678
+ ***
679
+
680
+ ### rawListeners()
681
+
682
+ > **rawListeners**\<`E`\>(`eventName`): (...`args`) => `void`[]
683
+
684
+ Defined in: node\_modules/@types/node/events.d.ts:326
685
+
686
+ Returns a copy of the array of listeners for the event named `eventName`,
687
+ including any wrappers (such as those created by `.once()`).
688
+
689
+ ```js
690
+ import { EventEmitter } from 'node:events';
691
+ const emitter = new EventEmitter();
692
+ emitter.once('log', () => console.log('log once'));
693
+
694
+ // Returns a new Array with a function `onceWrapper` which has a property
695
+ // `listener` which contains the original listener bound above
696
+ const listeners = emitter.rawListeners('log');
697
+ const logFnWrapper = listeners[0];
698
+
699
+ // Logs "log once" to the console and does not unbind the `once` event
700
+ logFnWrapper.listener();
701
+
702
+ // Logs "log once" to the console and removes the listener
703
+ logFnWrapper();
704
+
705
+ emitter.on('log', () => console.log('log persistently'));
706
+ // Will return a new Array with a single function bound by `.on()` above
707
+ const newListeners = emitter.rawListeners('log');
708
+
709
+ // Logs "log persistently" twice
710
+ newListeners[0]();
711
+ emitter.emit('log');
712
+ ```
713
+
714
+ #### Type Parameters
715
+
716
+ ##### E
717
+
718
+ `E` *extends* `string` \| `symbol`
719
+
720
+ #### Parameters
721
+
722
+ ##### eventName
723
+
724
+ `string` \| `symbol`
725
+
726
+ #### Returns
727
+
728
+ (...`args`) => `void`[]
729
+
730
+ #### Since
731
+
732
+ v9.4.0
733
+
734
+ #### Inherited from
735
+
736
+ `EventEmitter.rawListeners`
737
+
738
+ ***
739
+
740
+ ### removeAllListeners()
741
+
742
+ > **removeAllListeners**\<`E`\>(`eventName?`): `this`
743
+
744
+ Defined in: node\_modules/@types/node/events.d.ts:338
745
+
746
+ Removes all listeners, or those of the specified `eventName`.
747
+
748
+ It is bad practice to remove listeners added elsewhere in the code,
749
+ particularly when the `EventEmitter` instance was created by some other
750
+ component or module (e.g. sockets or file streams).
751
+
752
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
753
+
754
+ #### Type Parameters
755
+
756
+ ##### E
757
+
758
+ `E` *extends* `string` \| `symbol`
759
+
760
+ #### Parameters
761
+
762
+ ##### eventName?
763
+
764
+ `string` \| `symbol`
765
+
766
+ #### Returns
767
+
768
+ `this`
769
+
770
+ #### Since
771
+
772
+ v0.1.26
773
+
774
+ #### Inherited from
775
+
776
+ `EventEmitter.removeAllListeners`
777
+
778
+ ***
779
+
780
+ ### removeListener()
781
+
782
+ > **removeListener**\<`E`\>(`eventName`, `listener`): `this`
783
+
784
+ Defined in: node\_modules/@types/node/events.d.ts:425
785
+
786
+ Removes the specified `listener` from the listener array for the event named
787
+ `eventName`.
788
+
789
+ ```js
790
+ const callback = (stream) => {
791
+ console.log('someone connected!');
792
+ };
793
+ server.on('connection', callback);
794
+ // ...
795
+ server.removeListener('connection', callback);
796
+ ```
797
+
798
+ `removeListener()` will remove, at most, one instance of a listener from the
799
+ listener array. If any single listener has been added multiple times to the
800
+ listener array for the specified `eventName`, then `removeListener()` must be
801
+ called multiple times to remove each instance.
802
+
803
+ Once an event is emitted, all listeners attached to it at the
804
+ time of emitting are called in order. This implies that any
805
+ `removeListener()` or `removeAllListeners()` calls _after_ emitting and
806
+ _before_ the last listener finishes execution will not remove them from
807
+ `emit()` in progress. Subsequent events behave as expected.
808
+
809
+ ```js
810
+ import { EventEmitter } from 'node:events';
811
+ class MyEmitter extends EventEmitter {}
812
+ const myEmitter = new MyEmitter();
813
+
814
+ const callbackA = () => {
815
+ console.log('A');
816
+ myEmitter.removeListener('event', callbackB);
817
+ };
818
+
819
+ const callbackB = () => {
820
+ console.log('B');
821
+ };
822
+
823
+ myEmitter.on('event', callbackA);
824
+
825
+ myEmitter.on('event', callbackB);
826
+
827
+ // callbackA removes listener callbackB but it will still be called.
828
+ // Internal listener array at time of emit [callbackA, callbackB]
829
+ myEmitter.emit('event');
830
+ // Prints:
831
+ // A
832
+ // B
833
+
834
+ // callbackB is now removed.
835
+ // Internal listener array [callbackA]
836
+ myEmitter.emit('event');
837
+ // Prints:
838
+ // A
839
+ ```
840
+
841
+ Because listeners are managed using an internal array, calling this will
842
+ change the position indexes of any listener registered _after_ the listener
843
+ being removed. This will not impact the order in which listeners are called,
844
+ but it means that any copies of the listener array as returned by
845
+ the `emitter.listeners()` method will need to be recreated.
846
+
847
+ When a single function has been added as a handler multiple times for a single
848
+ event (as in the example below), `removeListener()` will remove the most
849
+ recently added instance. In the example the `once('ping')`
850
+ listener is removed:
851
+
852
+ ```js
853
+ import { EventEmitter } from 'node:events';
854
+ const ee = new EventEmitter();
855
+
856
+ function pong() {
857
+ console.log('pong');
858
+ }
859
+
860
+ ee.on('ping', pong);
861
+ ee.once('ping', pong);
862
+ ee.removeListener('ping', pong);
863
+
864
+ ee.emit('ping');
865
+ ee.emit('ping');
866
+ ```
867
+
868
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
869
+
870
+ #### Type Parameters
871
+
872
+ ##### E
873
+
874
+ `E` *extends* `string` \| `symbol`
875
+
876
+ #### Parameters
877
+
878
+ ##### eventName
879
+
880
+ `string` \| `symbol`
881
+
882
+ ##### listener
883
+
884
+ (...`args`) => `void`
885
+
886
+ #### Returns
887
+
888
+ `this`
889
+
890
+ #### Since
891
+
892
+ v0.1.26
893
+
894
+ #### Inherited from
895
+
896
+ `EventEmitter.removeListener`
897
+
898
+ ***
899
+
900
+ ### send()
901
+
902
+ > **send**(`data`, `cb?`): `void`
903
+
904
+ Defined in: [src/http/WebSocket.ts:54](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/WebSocket.ts#L54)
905
+
906
+ Sends data over the WebSocket connection.
907
+
908
+ #### Parameters
909
+
910
+ ##### data
911
+
912
+ `any`
913
+
914
+ The data to send.
915
+
916
+ ##### cb?
917
+
918
+ (`err?`) => `void`
919
+
920
+ Optional callback invoked on completion or error.
921
+
922
+ #### Returns
923
+
924
+ `void`
925
+
926
+ ***
927
+
928
+ ### setMaxListeners()
929
+
930
+ > **setMaxListeners**(`n`): `this`
931
+
932
+ Defined in: node\_modules/@types/node/events.d.ts:436
933
+
934
+ By default `EventEmitter`s will print a warning if more than `10` listeners are
935
+ added for a particular event. This is a useful default that helps finding
936
+ memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
937
+ modified for this specific `EventEmitter` instance. The value can be set to
938
+ `Infinity` (or `0`) to indicate an unlimited number of listeners.
939
+
940
+ Returns a reference to the `EventEmitter`, so that calls can be chained.
941
+
942
+ #### Parameters
943
+
944
+ ##### n
945
+
946
+ `number`
947
+
948
+ #### Returns
949
+
950
+ `this`
951
+
952
+ #### Since
953
+
954
+ v0.3.5
955
+
956
+ #### Inherited from
957
+
958
+ `EventEmitter.setMaxListeners`