@breautek/storm 5.0.1 → 6.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.
- package/CHANGELOG.md +24 -2
- package/bt-config-defaults.json +0 -1
- package/bt-config-sample.jsonc +41 -7
- package/docs/assets/highlight.css +92 -0
- package/docs/assets/main.js +58 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1367 -0
- package/docs/classes/Application.html +1278 -0
- package/docs/classes/BackendAuthenticationMiddleware.html +193 -0
- package/docs/classes/CORSMiddleware.html +259 -0
- package/docs/classes/ConfigLoader.html +168 -0
- package/docs/classes/Database.html +342 -0
- package/docs/classes/DatabaseCastObject.html +205 -0
- package/docs/classes/DatabaseConnection.html +552 -0
- package/docs/classes/DatabaseQueryError.html +374 -0
- package/docs/classes/DeadLockError.html +374 -0
- package/docs/classes/DiskSpaceError.html +364 -0
- package/docs/classes/DropTemporaryTableQuery.html +287 -0
- package/docs/classes/DuplicateEntryError.html +368 -0
- package/docs/classes/EntityNotFoundError.html +364 -0
- package/docs/classes/ExpiredTokenError.html +364 -0
- package/docs/classes/Handler.html +397 -0
- package/docs/classes/InternalError.html +364 -0
- package/docs/classes/InvalidCredentialsError.html +364 -0
- package/docs/classes/InvalidValueError.html +375 -0
- package/docs/classes/LineString.html +214 -0
- package/docs/classes/LockWaitTimeoutError.html +374 -0
- package/docs/classes/ManagedDatabaseConnection.html +412 -0
- package/docs/classes/Middleware.html +204 -0
- package/docs/classes/MissingConfigError.html +364 -0
- package/docs/classes/MissingParameterError.html +364 -0
- package/docs/classes/MySQLConnection.html +548 -0
- package/docs/classes/MySQLDatabase.html +355 -0
- package/docs/classes/NotImplementedError.html +364 -0
- package/docs/classes/Point.html +216 -0
- package/docs/classes/Polygon.html +214 -0
- package/docs/classes/Query.html +314 -0
- package/docs/classes/RawError.html +376 -0
- package/docs/classes/RawQuery.html +307 -0
- package/docs/classes/Request.html +377 -0
- package/docs/classes/Response.html +331 -0
- package/docs/classes/ResponseData.html +257 -0
- package/docs/classes/ServiceProvider.html +387 -0
- package/docs/classes/ServiceResponse.html +215 -0
- package/docs/classes/SetSessionVariableQuery.html +287 -0
- package/docs/classes/StormError.html +379 -0
- package/docs/classes/TemporaryTableQuery.html +292 -0
- package/docs/classes/Token.html +183 -0
- package/docs/classes/TokenManager.html +235 -0
- package/docs/classes/Transaction.html +269 -0
- package/docs/classes/UnauthorizedAccessError.html +364 -0
- package/docs/enums/ErrorCode.html +212 -0
- package/docs/enums/ExitCode.html +163 -0
- package/docs/enums/HTTPMethod.html +177 -0
- package/docs/enums/IsolationLevel.html +177 -0
- package/docs/enums/JWTError.html +163 -0
- package/docs/enums/StatusCode.html +485 -0
- package/docs/functions/formidable-1.html +145 -0
- package/docs/functions/getInstance.html +140 -0
- package/docs/index.html +228 -0
- package/docs/interfaces/IAdditionalErrorDetails.html +142 -0
- package/docs/interfaces/IAuthTokenData.html +174 -0
- package/docs/interfaces/ICloudwatchConfig.html +174 -0
- package/docs/interfaces/ICloudwatchCredentials.html +167 -0
- package/docs/interfaces/ICloudwatchStreamConfig.html +167 -0
- package/docs/interfaces/IConfig.html +227 -0
- package/docs/interfaces/IDatabaseConfig.html +200 -0
- package/docs/interfaces/IDatabaseConnection.html +334 -0
- package/docs/interfaces/IErrorResponse.html +188 -0
- package/docs/interfaces/IFormData.html +167 -0
- package/docs/interfaces/IHandler.html +173 -0
- package/docs/interfaces/IInsertQueryResult.html +174 -0
- package/docs/interfaces/IJWTVerifyOptions.html +160 -0
- package/docs/interfaces/IParameterMap.html +142 -0
- package/docs/interfaces/IQueryable.html +235 -0
- package/docs/interfaces/IRequestResponse.html +174 -0
- package/docs/interfaces/IServiceHeaders.html +142 -0
- package/docs/interfaces/ISetSessionVariableQueryInput.html +167 -0
- package/docs/interfaces/ITemporaryTableQueryInput.html +167 -0
- package/docs/interfaces/IUpdateQueryResult.html +167 -0
- package/docs/interfaces/formidable.EmitData.html +182 -0
- package/docs/interfaces/formidable.EventData.html +203 -0
- package/docs/interfaces/formidable.Fields.html +143 -0
- package/docs/interfaces/formidable.File.html +241 -0
- package/docs/interfaces/formidable.FileJSON.html +240 -0
- package/docs/interfaces/formidable.Files.html +143 -0
- package/docs/interfaces/formidable.Options.html +310 -0
- package/docs/interfaces/formidable.Part.html +693 -0
- package/docs/modules/formidable.html +161 -0
- package/docs/types/IDeleteQueryResult.html +136 -0
- package/docs/types/IHandlerError.html +141 -0
- package/docs/types/IHandlerResponse.html +147 -0
- package/docs/types/TCoordinate.html +136 -0
- package/docs/types/formidable.BufferEncoding.html +137 -0
- package/docs/types/formidable.DefaultOptions.html +137 -0
- package/docs/types/formidable.EnabledPlugins.html +137 -0
- package/docs/types/formidable.EventNames.html +137 -0
- package/docs/types/formidable.MappedParsers.html +137 -0
- package/docs/types/formidable.Plugin.html +137 -0
- package/docs/types/formidable.PluginFunction.html +152 -0
- package/docs/types/formidable.Plugins.html +137 -0
- package/lib/Application.d.ts +3 -0
- package/lib/Application.js +105 -63
- package/lib/Application.js.map +1 -1
- package/lib/IConfig.d.ts +15 -2
- package/lib/MySQLConnection.js +3 -3
- package/lib/MySQLConnection.js.map +1 -1
- package/lib/StatusCode.d.ts +1 -1
- package/lib/StatusCode.js +1 -1
- package/lib/Transaction.d.ts +4 -0
- package/lib/Transaction.js +4 -0
- package/lib/Transaction.js.map +1 -1
- package/lib/api.d.ts +1 -2
- package/lib/api.js +2 -4
- package/lib/api.js.map +1 -1
- package/package.json +18 -16
- package/src/Application.ts +131 -68
- package/src/IConfig.ts +18 -2
- package/src/MySQLConnection.ts +2 -1
- package/src/StatusCode.ts +1 -1
- package/src/Transaction.ts +4 -0
- package/src/api.ts +6 -2
- package/docs/README.md +0 -188
- package/docs/classes/Application.md +0 -1648
- package/docs/classes/BackendAuthenticationMiddleware.md +0 -49
- package/docs/classes/CORSMiddleware.md +0 -143
- package/docs/classes/ConfigLoader.md +0 -29
- package/docs/classes/Database.md +0 -259
- package/docs/classes/DatabaseCastObject.md +0 -79
- package/docs/classes/DatabaseConnection.md +0 -556
- package/docs/classes/DatabaseQueryError.md +0 -351
- package/docs/classes/DeadLockError.md +0 -349
- package/docs/classes/DiskSpaceError.md +0 -341
- package/docs/classes/DropTemporaryTableQuery.md +0 -207
- package/docs/classes/DumpStream.md +0 -23
- package/docs/classes/DuplicateEntryError.md +0 -343
- package/docs/classes/EntityNotFoundError.md +0 -341
- package/docs/classes/ExpiredTokenError.md +0 -341
- package/docs/classes/Handler.md +0 -302
- package/docs/classes/InternalError.md +0 -341
- package/docs/classes/InvalidCredentialsError.md +0 -341
- package/docs/classes/InvalidValueError.md +0 -349
- package/docs/classes/LineString.md +0 -101
- package/docs/classes/LockWaitTimeoutError.md +0 -349
- package/docs/classes/ManagedDatabaseConnection.md +0 -403
- package/docs/classes/Middleware.md +0 -72
- package/docs/classes/MissingConfigError.md +0 -341
- package/docs/classes/MissingParameterError.md +0 -341
- package/docs/classes/MySQLConnection.md +0 -569
- package/docs/classes/MySQLDatabase.md +0 -314
- package/docs/classes/NotImplementedError.md +0 -341
- package/docs/classes/Point.md +0 -102
- package/docs/classes/Polygon.md +0 -101
- package/docs/classes/Query.md +0 -227
- package/docs/classes/RawError.md +0 -351
- package/docs/classes/RawQuery.md +0 -224
- package/docs/classes/Request.md +0 -321
- package/docs/classes/Response.md +0 -242
- package/docs/classes/ResponseData.md +0 -144
- package/docs/classes/ServiceProvider.md +0 -296
- package/docs/classes/ServiceResponse.md +0 -89
- package/docs/classes/SetSessionVariableQuery.md +0 -207
- package/docs/classes/StormError.md +0 -343
- package/docs/classes/TemporaryTableQuery.md +0 -213
- package/docs/classes/Token.md +0 -43
- package/docs/classes/TokenManager.md +0 -105
- package/docs/classes/Transaction.md +0 -161
- package/docs/classes/UnauthorizedAccessError.md +0 -341
- package/docs/enums/ErrorCode.md +0 -107
- package/docs/enums/ExitCode.md +0 -30
- package/docs/enums/HTTPMethod.md +0 -52
- package/docs/enums/IsolationLevel.md +0 -52
- package/docs/enums/JWTError.md +0 -30
- package/docs/enums/StatusCode.md +0 -536
- package/docs/interfaces/IAdditionalErrorDetails.md +0 -7
- package/docs/interfaces/IAuthTokenData.md +0 -41
- package/docs/interfaces/IConfig.md +0 -112
- package/docs/interfaces/IDatabaseConfig.md +0 -80
- package/docs/interfaces/IDatabaseConnection.md +0 -262
- package/docs/interfaces/IErrorResponse.md +0 -63
- package/docs/interfaces/IFormData.md +0 -30
- package/docs/interfaces/IHandler.md +0 -31
- package/docs/interfaces/IInsertQueryResult.md +0 -41
- package/docs/interfaces/IJWTVerifyOptions.md +0 -19
- package/docs/interfaces/IParameterMap.md +0 -7
- package/docs/interfaces/IQueryable.md +0 -119
- package/docs/interfaces/IRequestResponse.md +0 -37
- package/docs/interfaces/IServiceHeaders.md +0 -7
- package/docs/interfaces/ISetSessionVariableQueryInput.md +0 -30
- package/docs/interfaces/ITemporaryTableQueryInput.md +0 -30
- package/docs/interfaces/IUpdateQueryResult.md +0 -30
- package/docs/interfaces/formidable.EmitData.md +0 -54
- package/docs/interfaces/formidable.EventData.md +0 -87
- package/docs/interfaces/formidable.Fields.md +0 -9
- package/docs/interfaces/formidable.File.md +0 -131
- package/docs/interfaces/formidable.FileJSON.md +0 -151
- package/docs/interfaces/formidable.Files.md +0 -9
- package/docs/interfaces/formidable.Options.md +0 -225
- package/docs/interfaces/formidable.Part.md +0 -793
- package/docs/modules/formidable.md +0 -122
- package/lib/DumpStream.d.ts +0 -6
- package/lib/DumpStream.js +0 -28
- package/lib/DumpStream.js.map +0 -1
- package/src/DumpStream.ts +0 -28
|
@@ -1,1648 +0,0 @@
|
|
|
1
|
-
[@breautek/storm](../README.md) / Application
|
|
2
|
-
|
|
3
|
-
# Class: Application<TConfig, TAuthToken, TDBConfig, TDBConnectionAPI\>
|
|
4
|
-
|
|
5
|
-
Main entry point for the Application. Should be extended and have the abstract methods implemented.
|
|
6
|
-
|
|
7
|
-
## Type parameters
|
|
8
|
-
|
|
9
|
-
| Name | Type |
|
|
10
|
-
| :------ | :------ |
|
|
11
|
-
| `TConfig` | extends [`IConfig`](../interfaces/IConfig.md) = [`IConfig`](../interfaces/IConfig.md) |
|
|
12
|
-
| `TAuthToken` | extends [`IAuthTokenData`](../interfaces/IAuthTokenData.md) = [`IAuthTokenData`](../interfaces/IAuthTokenData.md) |
|
|
13
|
-
| `TDBConfig` | `any` |
|
|
14
|
-
| `TDBConnectionAPI` | `any` |
|
|
15
|
-
|
|
16
|
-
## Hierarchy
|
|
17
|
-
|
|
18
|
-
- `EventEmitter`
|
|
19
|
-
|
|
20
|
-
↳ **`Application`**
|
|
21
|
-
|
|
22
|
-
## Table of contents
|
|
23
|
-
|
|
24
|
-
### Constructors
|
|
25
|
-
|
|
26
|
-
- [constructor](Application.md#constructor)
|
|
27
|
-
|
|
28
|
-
### Properties
|
|
29
|
-
|
|
30
|
-
- [captureRejectionSymbol](Application.md#capturerejectionsymbol)
|
|
31
|
-
- [captureRejections](Application.md#capturerejections)
|
|
32
|
-
- [defaultMaxListeners](Application.md#defaultmaxlisteners)
|
|
33
|
-
- [errorMonitor](Application.md#errormonitor)
|
|
34
|
-
|
|
35
|
-
### Methods
|
|
36
|
-
|
|
37
|
-
- [\_attachHandlers](Application.md#_attachhandlers)
|
|
38
|
-
- [\_buildArgOptions](Application.md#_buildargoptions)
|
|
39
|
-
- [\_closeDatabase](Application.md#_closedatabase)
|
|
40
|
-
- [\_closeSocket](Application.md#_closesocket)
|
|
41
|
-
- [\_initDB](Application.md#_initdb)
|
|
42
|
-
- [\_initLogger](Application.md#_initlogger)
|
|
43
|
-
- [\_initialize](Application.md#_initialize)
|
|
44
|
-
- [\_onBeforeReadyAsync](Application.md#_onbeforereadyasync)
|
|
45
|
-
- [\_onConfigLoad](Application.md#_onconfigload)
|
|
46
|
-
- [\_onReady](Application.md#_onready)
|
|
47
|
-
- [addListener](Application.md#addlistener)
|
|
48
|
-
- [attachHandler](Application.md#attachhandler)
|
|
49
|
-
- [attachHandlerInstance](Application.md#attachhandlerinstance)
|
|
50
|
-
- [close](Application.md#close)
|
|
51
|
-
- [emit](Application.md#emit)
|
|
52
|
-
- [eventNames](Application.md#eventnames)
|
|
53
|
-
- [getCmdLineArgs](Application.md#getcmdlineargs)
|
|
54
|
-
- [getConfig](Application.md#getconfig)
|
|
55
|
-
- [getDB](Application.md#getdb)
|
|
56
|
-
- [getLogger](Application.md#getlogger)
|
|
57
|
-
- [getMaxListeners](Application.md#getmaxlisteners)
|
|
58
|
-
- [getName](Application.md#getname)
|
|
59
|
-
- [getPort](Application.md#getport)
|
|
60
|
-
- [getProgram](Application.md#getprogram)
|
|
61
|
-
- [getRequestSizeLimit](Application.md#getrequestsizelimit)
|
|
62
|
-
- [getTokenManager](Application.md#gettokenmanager)
|
|
63
|
-
- [listenerCount](Application.md#listenercount)
|
|
64
|
-
- [listeners](Application.md#listeners)
|
|
65
|
-
- [loadConfig](Application.md#loadconfig)
|
|
66
|
-
- [off](Application.md#off)
|
|
67
|
-
- [on](Application.md#on)
|
|
68
|
-
- [once](Application.md#once)
|
|
69
|
-
- [prependListener](Application.md#prependlistener)
|
|
70
|
-
- [prependOnceListener](Application.md#prependoncelistener)
|
|
71
|
-
- [rawListeners](Application.md#rawlisteners)
|
|
72
|
-
- [removeAllListeners](Application.md#removealllisteners)
|
|
73
|
-
- [removeListener](Application.md#removelistener)
|
|
74
|
-
- [setMaxListeners](Application.md#setmaxlisteners)
|
|
75
|
-
- [setTokenManager](Application.md#settokenmanager)
|
|
76
|
-
- [shouldListen](Application.md#shouldlisten)
|
|
77
|
-
- [getEventListeners](Application.md#geteventlisteners)
|
|
78
|
-
- [listenerCount](Application.md#listenercount-1)
|
|
79
|
-
- [on](Application.md#on-1)
|
|
80
|
-
- [once](Application.md#once-1)
|
|
81
|
-
- [setMaxListeners](Application.md#setmaxlisteners-1)
|
|
82
|
-
|
|
83
|
-
## Constructors
|
|
84
|
-
|
|
85
|
-
### constructor
|
|
86
|
-
|
|
87
|
-
• **new Application**<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>(`name`, `configPath`)
|
|
88
|
-
|
|
89
|
-
#### Type parameters
|
|
90
|
-
|
|
91
|
-
| Name | Type |
|
|
92
|
-
| :------ | :------ |
|
|
93
|
-
| `TConfig` | extends [`IConfig`](../interfaces/IConfig.md) = [`IConfig`](../interfaces/IConfig.md) |
|
|
94
|
-
| `TAuthToken` | extends [`IAuthTokenData`](../interfaces/IAuthTokenData.md) = [`IAuthTokenData`](../interfaces/IAuthTokenData.md) |
|
|
95
|
-
| `TDBConfig` | `any` |
|
|
96
|
-
| `TDBConnectionAPI` | `any` |
|
|
97
|
-
|
|
98
|
-
#### Parameters
|
|
99
|
-
|
|
100
|
-
| Name | Type | Description |
|
|
101
|
-
| :------ | :------ | :------ |
|
|
102
|
-
| `name` | `string` | The application name |
|
|
103
|
-
| `configPath` | `string` | The directory where bt-config.json and bt-local-config.json can be found. Defaults to current working directory. |
|
|
104
|
-
|
|
105
|
-
#### Overrides
|
|
106
|
-
|
|
107
|
-
EventEmitter.constructor
|
|
108
|
-
|
|
109
|
-
#### Defined in
|
|
110
|
-
|
|
111
|
-
[src/Application.ts:64](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L64)
|
|
112
|
-
|
|
113
|
-
## Properties
|
|
114
|
-
|
|
115
|
-
### captureRejectionSymbol
|
|
116
|
-
|
|
117
|
-
▪ `Static` `Readonly` **captureRejectionSymbol**: typeof [`captureRejectionSymbol`](Application.md#capturerejectionsymbol)
|
|
118
|
-
|
|
119
|
-
#### Inherited from
|
|
120
|
-
|
|
121
|
-
EventEmitter.captureRejectionSymbol
|
|
122
|
-
|
|
123
|
-
#### Defined in
|
|
124
|
-
|
|
125
|
-
node_modules/@types/node/events.d.ts:328
|
|
126
|
-
|
|
127
|
-
___
|
|
128
|
-
|
|
129
|
-
### captureRejections
|
|
130
|
-
|
|
131
|
-
▪ `Static` **captureRejections**: `boolean`
|
|
132
|
-
|
|
133
|
-
Sets or gets the default captureRejection value for all emitters.
|
|
134
|
-
|
|
135
|
-
#### Inherited from
|
|
136
|
-
|
|
137
|
-
EventEmitter.captureRejections
|
|
138
|
-
|
|
139
|
-
#### Defined in
|
|
140
|
-
|
|
141
|
-
node_modules/@types/node/events.d.ts:333
|
|
142
|
-
|
|
143
|
-
___
|
|
144
|
-
|
|
145
|
-
### defaultMaxListeners
|
|
146
|
-
|
|
147
|
-
▪ `Static` **defaultMaxListeners**: `number`
|
|
148
|
-
|
|
149
|
-
#### Inherited from
|
|
150
|
-
|
|
151
|
-
EventEmitter.defaultMaxListeners
|
|
152
|
-
|
|
153
|
-
#### Defined in
|
|
154
|
-
|
|
155
|
-
node_modules/@types/node/events.d.ts:334
|
|
156
|
-
|
|
157
|
-
___
|
|
158
|
-
|
|
159
|
-
### errorMonitor
|
|
160
|
-
|
|
161
|
-
▪ `Static` `Readonly` **errorMonitor**: typeof [`errorMonitor`](Application.md#errormonitor)
|
|
162
|
-
|
|
163
|
-
This symbol shall be used to install a listener for only monitoring `'error'`
|
|
164
|
-
events. Listeners installed using this symbol are called before the regular
|
|
165
|
-
`'error'` listeners are called.
|
|
166
|
-
|
|
167
|
-
Installing a listener using this symbol does not change the behavior once an
|
|
168
|
-
`'error'` event is emitted, therefore the process will still crash if no
|
|
169
|
-
regular `'error'` listener is installed.
|
|
170
|
-
|
|
171
|
-
#### Inherited from
|
|
172
|
-
|
|
173
|
-
EventEmitter.errorMonitor
|
|
174
|
-
|
|
175
|
-
#### Defined in
|
|
176
|
-
|
|
177
|
-
node_modules/@types/node/events.d.ts:327
|
|
178
|
-
|
|
179
|
-
## Methods
|
|
180
|
-
|
|
181
|
-
### \_attachHandlers
|
|
182
|
-
|
|
183
|
-
▸ `Protected` `Abstract` **_attachHandlers**(): `Promise`<`void`\>
|
|
184
|
-
|
|
185
|
-
Subclasses are expected to attach the API handlers for their service. This will be invoked during application startup.
|
|
186
|
-
|
|
187
|
-
#### Returns
|
|
188
|
-
|
|
189
|
-
`Promise`<`void`\>
|
|
190
|
-
|
|
191
|
-
Promise<void>
|
|
192
|
-
|
|
193
|
-
#### Defined in
|
|
194
|
-
|
|
195
|
-
[src/Application.ts:272](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L272)
|
|
196
|
-
|
|
197
|
-
___
|
|
198
|
-
|
|
199
|
-
### \_buildArgOptions
|
|
200
|
-
|
|
201
|
-
▸ `Protected` **_buildArgOptions**(`program`): `void`
|
|
202
|
-
|
|
203
|
-
#### Parameters
|
|
204
|
-
|
|
205
|
-
| Name | Type |
|
|
206
|
-
| :------ | :------ |
|
|
207
|
-
| `program` | `Command` |
|
|
208
|
-
|
|
209
|
-
#### Returns
|
|
210
|
-
|
|
211
|
-
`void`
|
|
212
|
-
|
|
213
|
-
#### Defined in
|
|
214
|
-
|
|
215
|
-
[src/Application.ts:202](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L202)
|
|
216
|
-
|
|
217
|
-
___
|
|
218
|
-
|
|
219
|
-
### \_closeDatabase
|
|
220
|
-
|
|
221
|
-
▸ `Protected` **_closeDatabase**(): `Promise`<`void`\>
|
|
222
|
-
|
|
223
|
-
#### Returns
|
|
224
|
-
|
|
225
|
-
`Promise`<`void`\>
|
|
226
|
-
|
|
227
|
-
#### Defined in
|
|
228
|
-
|
|
229
|
-
[src/Application.ts:249](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L249)
|
|
230
|
-
|
|
231
|
-
___
|
|
232
|
-
|
|
233
|
-
### \_closeSocket
|
|
234
|
-
|
|
235
|
-
▸ `Protected` **_closeSocket**(): `Promise`<`void`\>
|
|
236
|
-
|
|
237
|
-
#### Returns
|
|
238
|
-
|
|
239
|
-
`Promise`<`void`\>
|
|
240
|
-
|
|
241
|
-
#### Defined in
|
|
242
|
-
|
|
243
|
-
[src/Application.ts:255](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L255)
|
|
244
|
-
|
|
245
|
-
___
|
|
246
|
-
|
|
247
|
-
### \_initDB
|
|
248
|
-
|
|
249
|
-
▸ `Protected` **_initDB**(`config`): `Promise`<[`Database`](Database.md)<`TDBConfig`, `TDBConnectionAPI`\>\>
|
|
250
|
-
|
|
251
|
-
Subclasses are expected to override this to configure their database setup, if the service uses a database.
|
|
252
|
-
|
|
253
|
-
#### Parameters
|
|
254
|
-
|
|
255
|
-
| Name | Type | Description |
|
|
256
|
-
| :------ | :------ | :------ |
|
|
257
|
-
| `config` | `TConfig` | The bt-config object |
|
|
258
|
-
|
|
259
|
-
#### Returns
|
|
260
|
-
|
|
261
|
-
`Promise`<[`Database`](Database.md)<`TDBConfig`, `TDBConnectionAPI`\>\>
|
|
262
|
-
|
|
263
|
-
#### Defined in
|
|
264
|
-
|
|
265
|
-
[src/Application.ts:381](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L381)
|
|
266
|
-
|
|
267
|
-
___
|
|
268
|
-
|
|
269
|
-
### \_initLogger
|
|
270
|
-
|
|
271
|
-
▸ `Protected` **_initLogger**(`config`): `Logger`
|
|
272
|
-
|
|
273
|
-
#### Parameters
|
|
274
|
-
|
|
275
|
-
| Name | Type |
|
|
276
|
-
| :------ | :------ |
|
|
277
|
-
| `config` | `TConfig` |
|
|
278
|
-
|
|
279
|
-
#### Returns
|
|
280
|
-
|
|
281
|
-
`Logger`
|
|
282
|
-
|
|
283
|
-
#### Defined in
|
|
284
|
-
|
|
285
|
-
[src/Application.ts:165](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L165)
|
|
286
|
-
|
|
287
|
-
___
|
|
288
|
-
|
|
289
|
-
### \_initialize
|
|
290
|
-
|
|
291
|
-
▸ `Protected` **_initialize**(`config`): `Promise`<`void`\>
|
|
292
|
-
|
|
293
|
-
#### Parameters
|
|
294
|
-
|
|
295
|
-
| Name | Type |
|
|
296
|
-
| :------ | :------ |
|
|
297
|
-
| `config` | `TConfig` |
|
|
298
|
-
|
|
299
|
-
#### Returns
|
|
300
|
-
|
|
301
|
-
`Promise`<`void`\>
|
|
302
|
-
|
|
303
|
-
#### Defined in
|
|
304
|
-
|
|
305
|
-
[src/Application.ts:161](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L161)
|
|
306
|
-
|
|
307
|
-
___
|
|
308
|
-
|
|
309
|
-
### \_onBeforeReadyAsync
|
|
310
|
-
|
|
311
|
-
▸ `Protected` **_onBeforeReadyAsync**(): `Promise`<`void`\>
|
|
312
|
-
|
|
313
|
-
#### Returns
|
|
314
|
-
|
|
315
|
-
`Promise`<`void`\>
|
|
316
|
-
|
|
317
|
-
#### Defined in
|
|
318
|
-
|
|
319
|
-
[src/Application.ts:385](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L385)
|
|
320
|
-
|
|
321
|
-
___
|
|
322
|
-
|
|
323
|
-
### \_onConfigLoad
|
|
324
|
-
|
|
325
|
-
▸ `Protected` **_onConfigLoad**(`config`): `void`
|
|
326
|
-
|
|
327
|
-
Invoked once the config has been loaded and ready to be used.
|
|
328
|
-
|
|
329
|
-
#### Parameters
|
|
330
|
-
|
|
331
|
-
| Name | Type | Description |
|
|
332
|
-
| :------ | :------ | :------ |
|
|
333
|
-
| `config` | `TConfig` | The config object (as defined in bt-config.json/bt-local-config.json) |
|
|
334
|
-
|
|
335
|
-
#### Returns
|
|
336
|
-
|
|
337
|
-
`void`
|
|
338
|
-
|
|
339
|
-
#### Defined in
|
|
340
|
-
|
|
341
|
-
[src/Application.ts:325](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L325)
|
|
342
|
-
|
|
343
|
-
___
|
|
344
|
-
|
|
345
|
-
### \_onReady
|
|
346
|
-
|
|
347
|
-
▸ `Protected` **_onReady**(): `void`
|
|
348
|
-
|
|
349
|
-
Invoked when the application is considered ready for operation.
|
|
350
|
-
|
|
351
|
-
#### Returns
|
|
352
|
-
|
|
353
|
-
`void`
|
|
354
|
-
|
|
355
|
-
#### Defined in
|
|
356
|
-
|
|
357
|
-
[src/Application.ts:390](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L390)
|
|
358
|
-
|
|
359
|
-
___
|
|
360
|
-
|
|
361
|
-
### addListener
|
|
362
|
-
|
|
363
|
-
▸ **addListener**(`eventName`, `listener`): [`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
364
|
-
|
|
365
|
-
Alias for `emitter.on(eventName, listener)`.
|
|
366
|
-
|
|
367
|
-
**`Since`**
|
|
368
|
-
|
|
369
|
-
v0.1.26
|
|
370
|
-
|
|
371
|
-
#### Parameters
|
|
372
|
-
|
|
373
|
-
| Name | Type |
|
|
374
|
-
| :------ | :------ |
|
|
375
|
-
| `eventName` | `string` \| `symbol` |
|
|
376
|
-
| `listener` | (...`args`: `any`[]) => `void` |
|
|
377
|
-
|
|
378
|
-
#### Returns
|
|
379
|
-
|
|
380
|
-
[`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
381
|
-
|
|
382
|
-
#### Inherited from
|
|
383
|
-
|
|
384
|
-
EventEmitter.addListener
|
|
385
|
-
|
|
386
|
-
#### Defined in
|
|
387
|
-
|
|
388
|
-
node_modules/@types/node/events.d.ts:354
|
|
389
|
-
|
|
390
|
-
___
|
|
391
|
-
|
|
392
|
-
### attachHandler
|
|
393
|
-
|
|
394
|
-
▸ **attachHandler**(`path`, `HandlerClass`): `void`
|
|
395
|
-
|
|
396
|
-
#### Parameters
|
|
397
|
-
|
|
398
|
-
| Name | Type | Description |
|
|
399
|
-
| :------ | :------ | :------ |
|
|
400
|
-
| `path` | `string` | The URL API path. E.g. /api/myService/myCommand/ |
|
|
401
|
-
| `HandlerClass` | [`IHandler`](../interfaces/IHandler.md)<[`Application`](Application.md)<[`IConfig`](../interfaces/IConfig.md), [`IAuthTokenData`](../interfaces/IAuthTokenData.md), `any`, `any`\>\> | The concrete class (not the instance) of Handler to be used for this API. |
|
|
402
|
-
|
|
403
|
-
#### Returns
|
|
404
|
-
|
|
405
|
-
`void`
|
|
406
|
-
|
|
407
|
-
#### Defined in
|
|
408
|
-
|
|
409
|
-
[src/Application.ts:221](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L221)
|
|
410
|
-
|
|
411
|
-
___
|
|
412
|
-
|
|
413
|
-
### attachHandlerInstance
|
|
414
|
-
|
|
415
|
-
▸ **attachHandlerInstance**(`path`, `handler`): `void`
|
|
416
|
-
|
|
417
|
-
#### Parameters
|
|
418
|
-
|
|
419
|
-
| Name | Type |
|
|
420
|
-
| :------ | :------ |
|
|
421
|
-
| `path` | `string` |
|
|
422
|
-
| `handler` | [`Handler`](Handler.md)<[`Application`](Application.md)<[`IConfig`](../interfaces/IConfig.md), [`IAuthTokenData`](../interfaces/IAuthTokenData.md), `any`, `any`\>, `any`, `any`, `any`, `any`, `any`, `any`, `any`, `any`\> |
|
|
423
|
-
|
|
424
|
-
#### Returns
|
|
425
|
-
|
|
426
|
-
`void`
|
|
427
|
-
|
|
428
|
-
#### Defined in
|
|
429
|
-
|
|
430
|
-
[src/Application.ts:226](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L226)
|
|
431
|
-
|
|
432
|
-
___
|
|
433
|
-
|
|
434
|
-
### close
|
|
435
|
-
|
|
436
|
-
▸ **close**(): `Promise`<`void`\>
|
|
437
|
-
|
|
438
|
-
#### Returns
|
|
439
|
-
|
|
440
|
-
`Promise`<`void`\>
|
|
441
|
-
|
|
442
|
-
#### Defined in
|
|
443
|
-
|
|
444
|
-
[src/Application.ts:245](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L245)
|
|
445
|
-
|
|
446
|
-
___
|
|
447
|
-
|
|
448
|
-
### emit
|
|
449
|
-
|
|
450
|
-
▸ **emit**(`eventName`, `...args`): `boolean`
|
|
451
|
-
|
|
452
|
-
Synchronously calls each of the listeners registered for the event named`eventName`, in the order they were registered, passing the supplied arguments
|
|
453
|
-
to each.
|
|
454
|
-
|
|
455
|
-
Returns `true` if the event had listeners, `false` otherwise.
|
|
456
|
-
|
|
457
|
-
```js
|
|
458
|
-
const EventEmitter = require('events');
|
|
459
|
-
const myEmitter = new EventEmitter();
|
|
460
|
-
|
|
461
|
-
// First listener
|
|
462
|
-
myEmitter.on('event', function firstListener() {
|
|
463
|
-
console.log('Helloooo! first listener');
|
|
464
|
-
});
|
|
465
|
-
// Second listener
|
|
466
|
-
myEmitter.on('event', function secondListener(arg1, arg2) {
|
|
467
|
-
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
|
|
468
|
-
});
|
|
469
|
-
// Third listener
|
|
470
|
-
myEmitter.on('event', function thirdListener(...args) {
|
|
471
|
-
const parameters = args.join(', ');
|
|
472
|
-
console.log(`event with parameters ${parameters} in third listener`);
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
console.log(myEmitter.listeners('event'));
|
|
476
|
-
|
|
477
|
-
myEmitter.emit('event', 1, 2, 3, 4, 5);
|
|
478
|
-
|
|
479
|
-
// Prints:
|
|
480
|
-
// [
|
|
481
|
-
// [Function: firstListener],
|
|
482
|
-
// [Function: secondListener],
|
|
483
|
-
// [Function: thirdListener]
|
|
484
|
-
// ]
|
|
485
|
-
// Helloooo! first listener
|
|
486
|
-
// event with parameters 1, 2 in second listener
|
|
487
|
-
// event with parameters 1, 2, 3, 4, 5 in third listener
|
|
488
|
-
```
|
|
489
|
-
|
|
490
|
-
**`Since`**
|
|
491
|
-
|
|
492
|
-
v0.1.26
|
|
493
|
-
|
|
494
|
-
#### Parameters
|
|
495
|
-
|
|
496
|
-
| Name | Type |
|
|
497
|
-
| :------ | :------ |
|
|
498
|
-
| `eventName` | `string` \| `symbol` |
|
|
499
|
-
| `...args` | `any`[] |
|
|
500
|
-
|
|
501
|
-
#### Returns
|
|
502
|
-
|
|
503
|
-
`boolean`
|
|
504
|
-
|
|
505
|
-
#### Inherited from
|
|
506
|
-
|
|
507
|
-
EventEmitter.emit
|
|
508
|
-
|
|
509
|
-
#### Defined in
|
|
510
|
-
|
|
511
|
-
node_modules/@types/node/events.d.ts:610
|
|
512
|
-
|
|
513
|
-
___
|
|
514
|
-
|
|
515
|
-
### eventNames
|
|
516
|
-
|
|
517
|
-
▸ **eventNames**(): (`string` \| `symbol`)[]
|
|
518
|
-
|
|
519
|
-
Returns an array listing the events for which the emitter has registered
|
|
520
|
-
listeners. The values in the array are strings or `Symbol`s.
|
|
521
|
-
|
|
522
|
-
```js
|
|
523
|
-
const EventEmitter = require('events');
|
|
524
|
-
const myEE = new EventEmitter();
|
|
525
|
-
myEE.on('foo', () => {});
|
|
526
|
-
myEE.on('bar', () => {});
|
|
527
|
-
|
|
528
|
-
const sym = Symbol('symbol');
|
|
529
|
-
myEE.on(sym, () => {});
|
|
530
|
-
|
|
531
|
-
console.log(myEE.eventNames());
|
|
532
|
-
// Prints: [ 'foo', 'bar', Symbol(symbol) ]
|
|
533
|
-
```
|
|
534
|
-
|
|
535
|
-
**`Since`**
|
|
536
|
-
|
|
537
|
-
v6.0.0
|
|
538
|
-
|
|
539
|
-
#### Returns
|
|
540
|
-
|
|
541
|
-
(`string` \| `symbol`)[]
|
|
542
|
-
|
|
543
|
-
#### Inherited from
|
|
544
|
-
|
|
545
|
-
EventEmitter.eventNames
|
|
546
|
-
|
|
547
|
-
#### Defined in
|
|
548
|
-
|
|
549
|
-
node_modules/@types/node/events.d.ts:669
|
|
550
|
-
|
|
551
|
-
___
|
|
552
|
-
|
|
553
|
-
### getCmdLineArgs
|
|
554
|
-
|
|
555
|
-
▸ **getCmdLineArgs**(): `TConfig`
|
|
556
|
-
|
|
557
|
-
#### Returns
|
|
558
|
-
|
|
559
|
-
`TConfig`
|
|
560
|
-
|
|
561
|
-
command line arguments
|
|
562
|
-
|
|
563
|
-
#### Defined in
|
|
564
|
-
|
|
565
|
-
[src/Application.ts:352](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L352)
|
|
566
|
-
|
|
567
|
-
___
|
|
568
|
-
|
|
569
|
-
### getConfig
|
|
570
|
-
|
|
571
|
-
▸ **getConfig**(): `TConfig`
|
|
572
|
-
|
|
573
|
-
#### Returns
|
|
574
|
-
|
|
575
|
-
`TConfig`
|
|
576
|
-
|
|
577
|
-
the config object.
|
|
578
|
-
|
|
579
|
-
#### Defined in
|
|
580
|
-
|
|
581
|
-
[src/Application.ts:309](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L309)
|
|
582
|
-
|
|
583
|
-
___
|
|
584
|
-
|
|
585
|
-
### getDB
|
|
586
|
-
|
|
587
|
-
▸ **getDB**(): [`Database`](Database.md)<`TDBConfig`, `TDBConnectionAPI`\>
|
|
588
|
-
|
|
589
|
-
#### Returns
|
|
590
|
-
|
|
591
|
-
[`Database`](Database.md)<`TDBConfig`, `TDBConnectionAPI`\>
|
|
592
|
-
|
|
593
|
-
the database pool. This will need to be casted based on your preferred database dialect.
|
|
594
|
-
|
|
595
|
-
#### Defined in
|
|
596
|
-
|
|
597
|
-
[src/Application.ts:345](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L345)
|
|
598
|
-
|
|
599
|
-
___
|
|
600
|
-
|
|
601
|
-
### getLogger
|
|
602
|
-
|
|
603
|
-
▸ **getLogger**(): `Logger`
|
|
604
|
-
|
|
605
|
-
#### Returns
|
|
606
|
-
|
|
607
|
-
`Logger`
|
|
608
|
-
|
|
609
|
-
#### Defined in
|
|
610
|
-
|
|
611
|
-
[src/Application.ts:169](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L169)
|
|
612
|
-
|
|
613
|
-
___
|
|
614
|
-
|
|
615
|
-
### getMaxListeners
|
|
616
|
-
|
|
617
|
-
▸ **getMaxListeners**(): `number`
|
|
618
|
-
|
|
619
|
-
Returns the current max listener value for the `EventEmitter` which is either
|
|
620
|
-
set by `emitter.setMaxListeners(n)` or defaults to [defaultMaxListeners](Application.md#defaultmaxlisteners).
|
|
621
|
-
|
|
622
|
-
**`Since`**
|
|
623
|
-
|
|
624
|
-
v1.0.0
|
|
625
|
-
|
|
626
|
-
#### Returns
|
|
627
|
-
|
|
628
|
-
`number`
|
|
629
|
-
|
|
630
|
-
#### Inherited from
|
|
631
|
-
|
|
632
|
-
EventEmitter.getMaxListeners
|
|
633
|
-
|
|
634
|
-
#### Defined in
|
|
635
|
-
|
|
636
|
-
node_modules/@types/node/events.d.ts:526
|
|
637
|
-
|
|
638
|
-
___
|
|
639
|
-
|
|
640
|
-
### getName
|
|
641
|
-
|
|
642
|
-
▸ **getName**(): `string`
|
|
643
|
-
|
|
644
|
-
#### Returns
|
|
645
|
-
|
|
646
|
-
`string`
|
|
647
|
-
|
|
648
|
-
the application name
|
|
649
|
-
|
|
650
|
-
#### Defined in
|
|
651
|
-
|
|
652
|
-
[src/Application.ts:298](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L298)
|
|
653
|
-
|
|
654
|
-
___
|
|
655
|
-
|
|
656
|
-
### getPort
|
|
657
|
-
|
|
658
|
-
▸ **getPort**(): `number`
|
|
659
|
-
|
|
660
|
-
#### Returns
|
|
661
|
-
|
|
662
|
-
`number`
|
|
663
|
-
|
|
664
|
-
#### Defined in
|
|
665
|
-
|
|
666
|
-
[src/Application.ts:173](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L173)
|
|
667
|
-
|
|
668
|
-
___
|
|
669
|
-
|
|
670
|
-
### getProgram
|
|
671
|
-
|
|
672
|
-
▸ **getProgram**(): `Command`
|
|
673
|
-
|
|
674
|
-
#### Returns
|
|
675
|
-
|
|
676
|
-
`Command`
|
|
677
|
-
|
|
678
|
-
#### Defined in
|
|
679
|
-
|
|
680
|
-
[src/Application.ts:204](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L204)
|
|
681
|
-
|
|
682
|
-
___
|
|
683
|
-
|
|
684
|
-
### getRequestSizeLimit
|
|
685
|
-
|
|
686
|
-
▸ **getRequestSizeLimit**(): `number`
|
|
687
|
-
|
|
688
|
-
The maximum size limit for incoming requests that this service needs to handle.
|
|
689
|
-
|
|
690
|
-
#### Returns
|
|
691
|
-
|
|
692
|
-
`number`
|
|
693
|
-
|
|
694
|
-
#### Defined in
|
|
695
|
-
|
|
696
|
-
[src/Application.ts:211](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L211)
|
|
697
|
-
|
|
698
|
-
___
|
|
699
|
-
|
|
700
|
-
### getTokenManager
|
|
701
|
-
|
|
702
|
-
▸ **getTokenManager**(): [`TokenManager`](TokenManager.md)<`TAuthToken`\>
|
|
703
|
-
|
|
704
|
-
#### Returns
|
|
705
|
-
|
|
706
|
-
[`TokenManager`](TokenManager.md)<`TAuthToken`\>
|
|
707
|
-
|
|
708
|
-
the token manager
|
|
709
|
-
|
|
710
|
-
#### Defined in
|
|
711
|
-
|
|
712
|
-
[src/Application.ts:338](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L338)
|
|
713
|
-
|
|
714
|
-
___
|
|
715
|
-
|
|
716
|
-
### listenerCount
|
|
717
|
-
|
|
718
|
-
▸ **listenerCount**(`eventName`): `number`
|
|
719
|
-
|
|
720
|
-
Returns the number of listeners listening to the event named `eventName`.
|
|
721
|
-
|
|
722
|
-
**`Since`**
|
|
723
|
-
|
|
724
|
-
v3.2.0
|
|
725
|
-
|
|
726
|
-
#### Parameters
|
|
727
|
-
|
|
728
|
-
| Name | Type | Description |
|
|
729
|
-
| :------ | :------ | :------ |
|
|
730
|
-
| `eventName` | `string` \| `symbol` | The name of the event being listened for |
|
|
731
|
-
|
|
732
|
-
#### Returns
|
|
733
|
-
|
|
734
|
-
`number`
|
|
735
|
-
|
|
736
|
-
#### Inherited from
|
|
737
|
-
|
|
738
|
-
EventEmitter.listenerCount
|
|
739
|
-
|
|
740
|
-
#### Defined in
|
|
741
|
-
|
|
742
|
-
node_modules/@types/node/events.d.ts:616
|
|
743
|
-
|
|
744
|
-
___
|
|
745
|
-
|
|
746
|
-
### listeners
|
|
747
|
-
|
|
748
|
-
▸ **listeners**(`eventName`): `Function`[]
|
|
749
|
-
|
|
750
|
-
Returns a copy of the array of listeners for the event named `eventName`.
|
|
751
|
-
|
|
752
|
-
```js
|
|
753
|
-
server.on('connection', (stream) => {
|
|
754
|
-
console.log('someone connected!');
|
|
755
|
-
});
|
|
756
|
-
console.log(util.inspect(server.listeners('connection')));
|
|
757
|
-
// Prints: [ [Function] ]
|
|
758
|
-
```
|
|
759
|
-
|
|
760
|
-
**`Since`**
|
|
761
|
-
|
|
762
|
-
v0.1.26
|
|
763
|
-
|
|
764
|
-
#### Parameters
|
|
765
|
-
|
|
766
|
-
| Name | Type |
|
|
767
|
-
| :------ | :------ |
|
|
768
|
-
| `eventName` | `string` \| `symbol` |
|
|
769
|
-
|
|
770
|
-
#### Returns
|
|
771
|
-
|
|
772
|
-
`Function`[]
|
|
773
|
-
|
|
774
|
-
#### Inherited from
|
|
775
|
-
|
|
776
|
-
EventEmitter.listeners
|
|
777
|
-
|
|
778
|
-
#### Defined in
|
|
779
|
-
|
|
780
|
-
node_modules/@types/node/events.d.ts:539
|
|
781
|
-
|
|
782
|
-
___
|
|
783
|
-
|
|
784
|
-
### loadConfig
|
|
785
|
-
|
|
786
|
-
▸ **loadConfig**(`path`): `Promise`<`TConfig`\>
|
|
787
|
-
|
|
788
|
-
#### Parameters
|
|
789
|
-
|
|
790
|
-
| Name | Type | Description |
|
|
791
|
-
| :------ | :------ | :------ |
|
|
792
|
-
| `path` | `string` | The directory path that contains bt-config.json and bt-local-config.json |
|
|
793
|
-
|
|
794
|
-
#### Returns
|
|
795
|
-
|
|
796
|
-
`Promise`<`TConfig`\>
|
|
797
|
-
|
|
798
|
-
#### Defined in
|
|
799
|
-
|
|
800
|
-
[src/Application.ts:278](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L278)
|
|
801
|
-
|
|
802
|
-
___
|
|
803
|
-
|
|
804
|
-
### off
|
|
805
|
-
|
|
806
|
-
▸ **off**(`eventName`, `listener`): [`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
807
|
-
|
|
808
|
-
Alias for `emitter.removeListener()`.
|
|
809
|
-
|
|
810
|
-
**`Since`**
|
|
811
|
-
|
|
812
|
-
v10.0.0
|
|
813
|
-
|
|
814
|
-
#### Parameters
|
|
815
|
-
|
|
816
|
-
| Name | Type |
|
|
817
|
-
| :------ | :------ |
|
|
818
|
-
| `eventName` | `string` \| `symbol` |
|
|
819
|
-
| `listener` | (...`args`: `any`[]) => `void` |
|
|
820
|
-
|
|
821
|
-
#### Returns
|
|
822
|
-
|
|
823
|
-
[`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
824
|
-
|
|
825
|
-
#### Inherited from
|
|
826
|
-
|
|
827
|
-
EventEmitter.off
|
|
828
|
-
|
|
829
|
-
#### Defined in
|
|
830
|
-
|
|
831
|
-
node_modules/@types/node/events.d.ts:499
|
|
832
|
-
|
|
833
|
-
___
|
|
834
|
-
|
|
835
|
-
### on
|
|
836
|
-
|
|
837
|
-
▸ **on**(`eventName`, `listener`): [`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
838
|
-
|
|
839
|
-
Adds the `listener` function to the end of the listeners array for the
|
|
840
|
-
event named `eventName`. No checks are made to see if the `listener` has
|
|
841
|
-
already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
|
|
842
|
-
times.
|
|
843
|
-
|
|
844
|
-
```js
|
|
845
|
-
server.on('connection', (stream) => {
|
|
846
|
-
console.log('someone connected!');
|
|
847
|
-
});
|
|
848
|
-
```
|
|
849
|
-
|
|
850
|
-
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
851
|
-
|
|
852
|
-
By default, event listeners are invoked in the order they are added. The`emitter.prependListener()` method can be used as an alternative to add the
|
|
853
|
-
event listener to the beginning of the listeners array.
|
|
854
|
-
|
|
855
|
-
```js
|
|
856
|
-
const myEE = new EventEmitter();
|
|
857
|
-
myEE.on('foo', () => console.log('a'));
|
|
858
|
-
myEE.prependListener('foo', () => console.log('b'));
|
|
859
|
-
myEE.emit('foo');
|
|
860
|
-
// Prints:
|
|
861
|
-
// b
|
|
862
|
-
// a
|
|
863
|
-
```
|
|
864
|
-
|
|
865
|
-
**`Since`**
|
|
866
|
-
|
|
867
|
-
v0.1.101
|
|
868
|
-
|
|
869
|
-
#### Parameters
|
|
870
|
-
|
|
871
|
-
| Name | Type | Description |
|
|
872
|
-
| :------ | :------ | :------ |
|
|
873
|
-
| `eventName` | `string` \| `symbol` | The name of the event. |
|
|
874
|
-
| `listener` | (...`args`: `any`[]) => `void` | The callback function |
|
|
875
|
-
|
|
876
|
-
#### Returns
|
|
877
|
-
|
|
878
|
-
[`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
879
|
-
|
|
880
|
-
#### Inherited from
|
|
881
|
-
|
|
882
|
-
EventEmitter.on
|
|
883
|
-
|
|
884
|
-
#### Defined in
|
|
885
|
-
|
|
886
|
-
node_modules/@types/node/events.d.ts:385
|
|
887
|
-
|
|
888
|
-
___
|
|
889
|
-
|
|
890
|
-
### once
|
|
891
|
-
|
|
892
|
-
▸ **once**(`eventName`, `listener`): [`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
893
|
-
|
|
894
|
-
Adds a **one-time**`listener` function for the event named `eventName`. The
|
|
895
|
-
next time `eventName` is triggered, this listener is removed and then invoked.
|
|
896
|
-
|
|
897
|
-
```js
|
|
898
|
-
server.once('connection', (stream) => {
|
|
899
|
-
console.log('Ah, we have our first user!');
|
|
900
|
-
});
|
|
901
|
-
```
|
|
902
|
-
|
|
903
|
-
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
904
|
-
|
|
905
|
-
By default, event listeners are invoked in the order they are added. The`emitter.prependOnceListener()` method can be used as an alternative to add the
|
|
906
|
-
event listener to the beginning of the listeners array.
|
|
907
|
-
|
|
908
|
-
```js
|
|
909
|
-
const myEE = new EventEmitter();
|
|
910
|
-
myEE.once('foo', () => console.log('a'));
|
|
911
|
-
myEE.prependOnceListener('foo', () => console.log('b'));
|
|
912
|
-
myEE.emit('foo');
|
|
913
|
-
// Prints:
|
|
914
|
-
// b
|
|
915
|
-
// a
|
|
916
|
-
```
|
|
917
|
-
|
|
918
|
-
**`Since`**
|
|
919
|
-
|
|
920
|
-
v0.3.0
|
|
921
|
-
|
|
922
|
-
#### Parameters
|
|
923
|
-
|
|
924
|
-
| Name | Type | Description |
|
|
925
|
-
| :------ | :------ | :------ |
|
|
926
|
-
| `eventName` | `string` \| `symbol` | The name of the event. |
|
|
927
|
-
| `listener` | (...`args`: `any`[]) => `void` | The callback function |
|
|
928
|
-
|
|
929
|
-
#### Returns
|
|
930
|
-
|
|
931
|
-
[`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
932
|
-
|
|
933
|
-
#### Inherited from
|
|
934
|
-
|
|
935
|
-
EventEmitter.once
|
|
936
|
-
|
|
937
|
-
#### Defined in
|
|
938
|
-
|
|
939
|
-
node_modules/@types/node/events.d.ts:414
|
|
940
|
-
|
|
941
|
-
___
|
|
942
|
-
|
|
943
|
-
### prependListener
|
|
944
|
-
|
|
945
|
-
▸ **prependListener**(`eventName`, `listener`): [`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
946
|
-
|
|
947
|
-
Adds the `listener` function to the _beginning_ of the listeners array for the
|
|
948
|
-
event named `eventName`. No checks are made to see if the `listener` has
|
|
949
|
-
already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
|
|
950
|
-
times.
|
|
951
|
-
|
|
952
|
-
```js
|
|
953
|
-
server.prependListener('connection', (stream) => {
|
|
954
|
-
console.log('someone connected!');
|
|
955
|
-
});
|
|
956
|
-
```
|
|
957
|
-
|
|
958
|
-
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
959
|
-
|
|
960
|
-
**`Since`**
|
|
961
|
-
|
|
962
|
-
v6.0.0
|
|
963
|
-
|
|
964
|
-
#### Parameters
|
|
965
|
-
|
|
966
|
-
| Name | Type | Description |
|
|
967
|
-
| :------ | :------ | :------ |
|
|
968
|
-
| `eventName` | `string` \| `symbol` | The name of the event. |
|
|
969
|
-
| `listener` | (...`args`: `any`[]) => `void` | The callback function |
|
|
970
|
-
|
|
971
|
-
#### Returns
|
|
972
|
-
|
|
973
|
-
[`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
974
|
-
|
|
975
|
-
#### Inherited from
|
|
976
|
-
|
|
977
|
-
EventEmitter.prependListener
|
|
978
|
-
|
|
979
|
-
#### Defined in
|
|
980
|
-
|
|
981
|
-
node_modules/@types/node/events.d.ts:634
|
|
982
|
-
|
|
983
|
-
___
|
|
984
|
-
|
|
985
|
-
### prependOnceListener
|
|
986
|
-
|
|
987
|
-
▸ **prependOnceListener**(`eventName`, `listener`): [`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
988
|
-
|
|
989
|
-
Adds a **one-time**`listener` function for the event named `eventName` to the _beginning_ of the listeners array. The next time `eventName` is triggered, this
|
|
990
|
-
listener is removed, and then invoked.
|
|
991
|
-
|
|
992
|
-
```js
|
|
993
|
-
server.prependOnceListener('connection', (stream) => {
|
|
994
|
-
console.log('Ah, we have our first user!');
|
|
995
|
-
});
|
|
996
|
-
```
|
|
997
|
-
|
|
998
|
-
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
999
|
-
|
|
1000
|
-
**`Since`**
|
|
1001
|
-
|
|
1002
|
-
v6.0.0
|
|
1003
|
-
|
|
1004
|
-
#### Parameters
|
|
1005
|
-
|
|
1006
|
-
| Name | Type | Description |
|
|
1007
|
-
| :------ | :------ | :------ |
|
|
1008
|
-
| `eventName` | `string` \| `symbol` | The name of the event. |
|
|
1009
|
-
| `listener` | (...`args`: `any`[]) => `void` | The callback function |
|
|
1010
|
-
|
|
1011
|
-
#### Returns
|
|
1012
|
-
|
|
1013
|
-
[`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
1014
|
-
|
|
1015
|
-
#### Inherited from
|
|
1016
|
-
|
|
1017
|
-
EventEmitter.prependOnceListener
|
|
1018
|
-
|
|
1019
|
-
#### Defined in
|
|
1020
|
-
|
|
1021
|
-
node_modules/@types/node/events.d.ts:650
|
|
1022
|
-
|
|
1023
|
-
___
|
|
1024
|
-
|
|
1025
|
-
### rawListeners
|
|
1026
|
-
|
|
1027
|
-
▸ **rawListeners**(`eventName`): `Function`[]
|
|
1028
|
-
|
|
1029
|
-
Returns a copy of the array of listeners for the event named `eventName`,
|
|
1030
|
-
including any wrappers (such as those created by `.once()`).
|
|
1031
|
-
|
|
1032
|
-
```js
|
|
1033
|
-
const emitter = new EventEmitter();
|
|
1034
|
-
emitter.once('log', () => console.log('log once'));
|
|
1035
|
-
|
|
1036
|
-
// Returns a new Array with a function `onceWrapper` which has a property
|
|
1037
|
-
// `listener` which contains the original listener bound above
|
|
1038
|
-
const listeners = emitter.rawListeners('log');
|
|
1039
|
-
const logFnWrapper = listeners[0];
|
|
1040
|
-
|
|
1041
|
-
// Logs "log once" to the console and does not unbind the `once` event
|
|
1042
|
-
logFnWrapper.listener();
|
|
1043
|
-
|
|
1044
|
-
// Logs "log once" to the console and removes the listener
|
|
1045
|
-
logFnWrapper();
|
|
1046
|
-
|
|
1047
|
-
emitter.on('log', () => console.log('log persistently'));
|
|
1048
|
-
// Will return a new Array with a single function bound by `.on()` above
|
|
1049
|
-
const newListeners = emitter.rawListeners('log');
|
|
1050
|
-
|
|
1051
|
-
// Logs "log persistently" twice
|
|
1052
|
-
newListeners[0]();
|
|
1053
|
-
emitter.emit('log');
|
|
1054
|
-
```
|
|
1055
|
-
|
|
1056
|
-
**`Since`**
|
|
1057
|
-
|
|
1058
|
-
v9.4.0
|
|
1059
|
-
|
|
1060
|
-
#### Parameters
|
|
1061
|
-
|
|
1062
|
-
| Name | Type |
|
|
1063
|
-
| :------ | :------ |
|
|
1064
|
-
| `eventName` | `string` \| `symbol` |
|
|
1065
|
-
|
|
1066
|
-
#### Returns
|
|
1067
|
-
|
|
1068
|
-
`Function`[]
|
|
1069
|
-
|
|
1070
|
-
#### Inherited from
|
|
1071
|
-
|
|
1072
|
-
EventEmitter.rawListeners
|
|
1073
|
-
|
|
1074
|
-
#### Defined in
|
|
1075
|
-
|
|
1076
|
-
node_modules/@types/node/events.d.ts:569
|
|
1077
|
-
|
|
1078
|
-
___
|
|
1079
|
-
|
|
1080
|
-
### removeAllListeners
|
|
1081
|
-
|
|
1082
|
-
▸ **removeAllListeners**(`event?`): [`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
1083
|
-
|
|
1084
|
-
Removes all listeners, or those of the specified `eventName`.
|
|
1085
|
-
|
|
1086
|
-
It is bad practice to remove listeners added elsewhere in the code,
|
|
1087
|
-
particularly when the `EventEmitter` instance was created by some other
|
|
1088
|
-
component or module (e.g. sockets or file streams).
|
|
1089
|
-
|
|
1090
|
-
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
1091
|
-
|
|
1092
|
-
**`Since`**
|
|
1093
|
-
|
|
1094
|
-
v0.1.26
|
|
1095
|
-
|
|
1096
|
-
#### Parameters
|
|
1097
|
-
|
|
1098
|
-
| Name | Type |
|
|
1099
|
-
| :------ | :------ |
|
|
1100
|
-
| `event?` | `string` \| `symbol` |
|
|
1101
|
-
|
|
1102
|
-
#### Returns
|
|
1103
|
-
|
|
1104
|
-
[`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
1105
|
-
|
|
1106
|
-
#### Inherited from
|
|
1107
|
-
|
|
1108
|
-
EventEmitter.removeAllListeners
|
|
1109
|
-
|
|
1110
|
-
#### Defined in
|
|
1111
|
-
|
|
1112
|
-
node_modules/@types/node/events.d.ts:510
|
|
1113
|
-
|
|
1114
|
-
___
|
|
1115
|
-
|
|
1116
|
-
### removeListener
|
|
1117
|
-
|
|
1118
|
-
▸ **removeListener**(`eventName`, `listener`): [`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
1119
|
-
|
|
1120
|
-
Removes the specified `listener` from the listener array for the event named`eventName`.
|
|
1121
|
-
|
|
1122
|
-
```js
|
|
1123
|
-
const callback = (stream) => {
|
|
1124
|
-
console.log('someone connected!');
|
|
1125
|
-
};
|
|
1126
|
-
server.on('connection', callback);
|
|
1127
|
-
// ...
|
|
1128
|
-
server.removeListener('connection', callback);
|
|
1129
|
-
```
|
|
1130
|
-
|
|
1131
|
-
`removeListener()` will remove, at most, one instance of a listener from the
|
|
1132
|
-
listener array. If any single listener has been added multiple times to the
|
|
1133
|
-
listener array for the specified `eventName`, then `removeListener()` must be
|
|
1134
|
-
called multiple times to remove each instance.
|
|
1135
|
-
|
|
1136
|
-
Once an event is emitted, all listeners attached to it at the
|
|
1137
|
-
time of emitting are called in order. This implies that any`removeListener()` or `removeAllListeners()` calls _after_ emitting and _before_ the last listener finishes execution
|
|
1138
|
-
will not remove them from`emit()` in progress. Subsequent events behave as expected.
|
|
1139
|
-
|
|
1140
|
-
```js
|
|
1141
|
-
const myEmitter = new MyEmitter();
|
|
1142
|
-
|
|
1143
|
-
const callbackA = () => {
|
|
1144
|
-
console.log('A');
|
|
1145
|
-
myEmitter.removeListener('event', callbackB);
|
|
1146
|
-
};
|
|
1147
|
-
|
|
1148
|
-
const callbackB = () => {
|
|
1149
|
-
console.log('B');
|
|
1150
|
-
};
|
|
1151
|
-
|
|
1152
|
-
myEmitter.on('event', callbackA);
|
|
1153
|
-
|
|
1154
|
-
myEmitter.on('event', callbackB);
|
|
1155
|
-
|
|
1156
|
-
// callbackA removes listener callbackB but it will still be called.
|
|
1157
|
-
// Internal listener array at time of emit [callbackA, callbackB]
|
|
1158
|
-
myEmitter.emit('event');
|
|
1159
|
-
// Prints:
|
|
1160
|
-
// A
|
|
1161
|
-
// B
|
|
1162
|
-
|
|
1163
|
-
// callbackB is now removed.
|
|
1164
|
-
// Internal listener array [callbackA]
|
|
1165
|
-
myEmitter.emit('event');
|
|
1166
|
-
// Prints:
|
|
1167
|
-
// A
|
|
1168
|
-
```
|
|
1169
|
-
|
|
1170
|
-
Because listeners are managed using an internal array, calling this will
|
|
1171
|
-
change the position indices of any listener registered _after_ the listener
|
|
1172
|
-
being removed. This will not impact the order in which listeners are called,
|
|
1173
|
-
but it means that any copies of the listener array as returned by
|
|
1174
|
-
the `emitter.listeners()` method will need to be recreated.
|
|
1175
|
-
|
|
1176
|
-
When a single function has been added as a handler multiple times for a single
|
|
1177
|
-
event (as in the example below), `removeListener()` will remove the most
|
|
1178
|
-
recently added instance. In the example the `once('ping')`listener is removed:
|
|
1179
|
-
|
|
1180
|
-
```js
|
|
1181
|
-
const ee = new EventEmitter();
|
|
1182
|
-
|
|
1183
|
-
function pong() {
|
|
1184
|
-
console.log('pong');
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
ee.on('ping', pong);
|
|
1188
|
-
ee.once('ping', pong);
|
|
1189
|
-
ee.removeListener('ping', pong);
|
|
1190
|
-
|
|
1191
|
-
ee.emit('ping');
|
|
1192
|
-
ee.emit('ping');
|
|
1193
|
-
```
|
|
1194
|
-
|
|
1195
|
-
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
1196
|
-
|
|
1197
|
-
**`Since`**
|
|
1198
|
-
|
|
1199
|
-
v0.1.26
|
|
1200
|
-
|
|
1201
|
-
#### Parameters
|
|
1202
|
-
|
|
1203
|
-
| Name | Type |
|
|
1204
|
-
| :------ | :------ |
|
|
1205
|
-
| `eventName` | `string` \| `symbol` |
|
|
1206
|
-
| `listener` | (...`args`: `any`[]) => `void` |
|
|
1207
|
-
|
|
1208
|
-
#### Returns
|
|
1209
|
-
|
|
1210
|
-
[`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
1211
|
-
|
|
1212
|
-
#### Inherited from
|
|
1213
|
-
|
|
1214
|
-
EventEmitter.removeListener
|
|
1215
|
-
|
|
1216
|
-
#### Defined in
|
|
1217
|
-
|
|
1218
|
-
node_modules/@types/node/events.d.ts:494
|
|
1219
|
-
|
|
1220
|
-
___
|
|
1221
|
-
|
|
1222
|
-
### setMaxListeners
|
|
1223
|
-
|
|
1224
|
-
▸ **setMaxListeners**(`n`): [`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
1225
|
-
|
|
1226
|
-
By default `EventEmitter`s will print a warning if more than `10` listeners are
|
|
1227
|
-
added for a particular event. This is a useful default that helps finding
|
|
1228
|
-
memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
|
|
1229
|
-
modified for this specific `EventEmitter` instance. The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
|
|
1230
|
-
|
|
1231
|
-
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
1232
|
-
|
|
1233
|
-
**`Since`**
|
|
1234
|
-
|
|
1235
|
-
v0.3.5
|
|
1236
|
-
|
|
1237
|
-
#### Parameters
|
|
1238
|
-
|
|
1239
|
-
| Name | Type |
|
|
1240
|
-
| :------ | :------ |
|
|
1241
|
-
| `n` | `number` |
|
|
1242
|
-
|
|
1243
|
-
#### Returns
|
|
1244
|
-
|
|
1245
|
-
[`Application`](Application.md)<`TConfig`, `TAuthToken`, `TDBConfig`, `TDBConnectionAPI`\>
|
|
1246
|
-
|
|
1247
|
-
#### Inherited from
|
|
1248
|
-
|
|
1249
|
-
EventEmitter.setMaxListeners
|
|
1250
|
-
|
|
1251
|
-
#### Defined in
|
|
1252
|
-
|
|
1253
|
-
node_modules/@types/node/events.d.ts:520
|
|
1254
|
-
|
|
1255
|
-
___
|
|
1256
|
-
|
|
1257
|
-
### setTokenManager
|
|
1258
|
-
|
|
1259
|
-
▸ **setTokenManager**(`tokenManager`): `void`
|
|
1260
|
-
|
|
1261
|
-
Sets the TokenManager to be used for authentication.
|
|
1262
|
-
|
|
1263
|
-
#### Parameters
|
|
1264
|
-
|
|
1265
|
-
| Name | Type |
|
|
1266
|
-
| :------ | :------ |
|
|
1267
|
-
| `tokenManager` | [`TokenManager`](TokenManager.md)<`TAuthToken`\> |
|
|
1268
|
-
|
|
1269
|
-
#### Returns
|
|
1270
|
-
|
|
1271
|
-
`void`
|
|
1272
|
-
|
|
1273
|
-
#### Defined in
|
|
1274
|
-
|
|
1275
|
-
[src/Application.ts:331](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L331)
|
|
1276
|
-
|
|
1277
|
-
___
|
|
1278
|
-
|
|
1279
|
-
### shouldListen
|
|
1280
|
-
|
|
1281
|
-
▸ **shouldListen**(): `boolean`
|
|
1282
|
-
|
|
1283
|
-
#### Returns
|
|
1284
|
-
|
|
1285
|
-
`boolean`
|
|
1286
|
-
|
|
1287
|
-
true if the Application should bind to an IP address
|
|
1288
|
-
|
|
1289
|
-
#### Defined in
|
|
1290
|
-
|
|
1291
|
-
[src/Application.ts:316](https://github.com/breautek/storm/blob/3dcafe4/src/Application.ts#L316)
|
|
1292
|
-
|
|
1293
|
-
___
|
|
1294
|
-
|
|
1295
|
-
### getEventListeners
|
|
1296
|
-
|
|
1297
|
-
▸ `Static` **getEventListeners**(`emitter`, `name`): `Function`[]
|
|
1298
|
-
|
|
1299
|
-
Returns a copy of the array of listeners for the event named `eventName`.
|
|
1300
|
-
|
|
1301
|
-
For `EventEmitter`s this behaves exactly the same as calling `.listeners` on
|
|
1302
|
-
the emitter.
|
|
1303
|
-
|
|
1304
|
-
For `EventTarget`s this is the only way to get the event listeners for the
|
|
1305
|
-
event target. This is useful for debugging and diagnostic purposes.
|
|
1306
|
-
|
|
1307
|
-
```js
|
|
1308
|
-
const { getEventListeners, EventEmitter } = require('events');
|
|
1309
|
-
|
|
1310
|
-
{
|
|
1311
|
-
const ee = new EventEmitter();
|
|
1312
|
-
const listener = () => console.log('Events are fun');
|
|
1313
|
-
ee.on('foo', listener);
|
|
1314
|
-
getEventListeners(ee, 'foo'); // [listener]
|
|
1315
|
-
}
|
|
1316
|
-
{
|
|
1317
|
-
const et = new EventTarget();
|
|
1318
|
-
const listener = () => console.log('Events are fun');
|
|
1319
|
-
et.addEventListener('foo', listener);
|
|
1320
|
-
getEventListeners(et, 'foo'); // [listener]
|
|
1321
|
-
}
|
|
1322
|
-
```
|
|
1323
|
-
|
|
1324
|
-
**`Since`**
|
|
1325
|
-
|
|
1326
|
-
v15.2.0, v14.17.0
|
|
1327
|
-
|
|
1328
|
-
#### Parameters
|
|
1329
|
-
|
|
1330
|
-
| Name | Type |
|
|
1331
|
-
| :------ | :------ |
|
|
1332
|
-
| `emitter` | `EventEmitter` \| `_DOMEventTarget` |
|
|
1333
|
-
| `name` | `string` \| `symbol` |
|
|
1334
|
-
|
|
1335
|
-
#### Returns
|
|
1336
|
-
|
|
1337
|
-
`Function`[]
|
|
1338
|
-
|
|
1339
|
-
#### Inherited from
|
|
1340
|
-
|
|
1341
|
-
EventEmitter.getEventListeners
|
|
1342
|
-
|
|
1343
|
-
#### Defined in
|
|
1344
|
-
|
|
1345
|
-
node_modules/@types/node/events.d.ts:299
|
|
1346
|
-
|
|
1347
|
-
___
|
|
1348
|
-
|
|
1349
|
-
### listenerCount
|
|
1350
|
-
|
|
1351
|
-
▸ `Static` **listenerCount**(`emitter`, `eventName`): `number`
|
|
1352
|
-
|
|
1353
|
-
A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
|
|
1354
|
-
|
|
1355
|
-
```js
|
|
1356
|
-
const { EventEmitter, listenerCount } = require('events');
|
|
1357
|
-
const myEmitter = new EventEmitter();
|
|
1358
|
-
myEmitter.on('event', () => {});
|
|
1359
|
-
myEmitter.on('event', () => {});
|
|
1360
|
-
console.log(listenerCount(myEmitter, 'event'));
|
|
1361
|
-
// Prints: 2
|
|
1362
|
-
```
|
|
1363
|
-
|
|
1364
|
-
**`Since`**
|
|
1365
|
-
|
|
1366
|
-
v0.9.12
|
|
1367
|
-
|
|
1368
|
-
**`Deprecated`**
|
|
1369
|
-
|
|
1370
|
-
Since v3.2.0 - Use `listenerCount` instead.
|
|
1371
|
-
|
|
1372
|
-
#### Parameters
|
|
1373
|
-
|
|
1374
|
-
| Name | Type | Description |
|
|
1375
|
-
| :------ | :------ | :------ |
|
|
1376
|
-
| `emitter` | `EventEmitter` | The emitter to query |
|
|
1377
|
-
| `eventName` | `string` \| `symbol` | The event name |
|
|
1378
|
-
|
|
1379
|
-
#### Returns
|
|
1380
|
-
|
|
1381
|
-
`number`
|
|
1382
|
-
|
|
1383
|
-
#### Inherited from
|
|
1384
|
-
|
|
1385
|
-
EventEmitter.listenerCount
|
|
1386
|
-
|
|
1387
|
-
#### Defined in
|
|
1388
|
-
|
|
1389
|
-
node_modules/@types/node/events.d.ts:271
|
|
1390
|
-
|
|
1391
|
-
___
|
|
1392
|
-
|
|
1393
|
-
### on
|
|
1394
|
-
|
|
1395
|
-
▸ `Static` **on**(`emitter`, `eventName`, `options?`): `AsyncIterableIterator`<`any`\>
|
|
1396
|
-
|
|
1397
|
-
```js
|
|
1398
|
-
const { on, EventEmitter } = require('events');
|
|
1399
|
-
|
|
1400
|
-
(async () => {
|
|
1401
|
-
const ee = new EventEmitter();
|
|
1402
|
-
|
|
1403
|
-
// Emit later on
|
|
1404
|
-
process.nextTick(() => {
|
|
1405
|
-
ee.emit('foo', 'bar');
|
|
1406
|
-
ee.emit('foo', 42);
|
|
1407
|
-
});
|
|
1408
|
-
|
|
1409
|
-
for await (const event of on(ee, 'foo')) {
|
|
1410
|
-
// The execution of this inner block is synchronous and it
|
|
1411
|
-
// processes one event at a time (even with await). Do not use
|
|
1412
|
-
// if concurrent execution is required.
|
|
1413
|
-
console.log(event); // prints ['bar'] [42]
|
|
1414
|
-
}
|
|
1415
|
-
// Unreachable here
|
|
1416
|
-
})();
|
|
1417
|
-
```
|
|
1418
|
-
|
|
1419
|
-
Returns an `AsyncIterator` that iterates `eventName` events. It will throw
|
|
1420
|
-
if the `EventEmitter` emits `'error'`. It removes all listeners when
|
|
1421
|
-
exiting the loop. The `value` returned by each iteration is an array
|
|
1422
|
-
composed of the emitted event arguments.
|
|
1423
|
-
|
|
1424
|
-
An `AbortSignal` can be used to cancel waiting on events:
|
|
1425
|
-
|
|
1426
|
-
```js
|
|
1427
|
-
const { on, EventEmitter } = require('events');
|
|
1428
|
-
const ac = new AbortController();
|
|
1429
|
-
|
|
1430
|
-
(async () => {
|
|
1431
|
-
const ee = new EventEmitter();
|
|
1432
|
-
|
|
1433
|
-
// Emit later on
|
|
1434
|
-
process.nextTick(() => {
|
|
1435
|
-
ee.emit('foo', 'bar');
|
|
1436
|
-
ee.emit('foo', 42);
|
|
1437
|
-
});
|
|
1438
|
-
|
|
1439
|
-
for await (const event of on(ee, 'foo', { signal: ac.signal })) {
|
|
1440
|
-
// The execution of this inner block is synchronous and it
|
|
1441
|
-
// processes one event at a time (even with await). Do not use
|
|
1442
|
-
// if concurrent execution is required.
|
|
1443
|
-
console.log(event); // prints ['bar'] [42]
|
|
1444
|
-
}
|
|
1445
|
-
// Unreachable here
|
|
1446
|
-
})();
|
|
1447
|
-
|
|
1448
|
-
process.nextTick(() => ac.abort());
|
|
1449
|
-
```
|
|
1450
|
-
|
|
1451
|
-
**`Since`**
|
|
1452
|
-
|
|
1453
|
-
v13.6.0, v12.16.0
|
|
1454
|
-
|
|
1455
|
-
#### Parameters
|
|
1456
|
-
|
|
1457
|
-
| Name | Type | Description |
|
|
1458
|
-
| :------ | :------ | :------ |
|
|
1459
|
-
| `emitter` | `EventEmitter` | - |
|
|
1460
|
-
| `eventName` | `string` | The name of the event being listened for |
|
|
1461
|
-
| `options?` | `StaticEventEmitterOptions` | - |
|
|
1462
|
-
|
|
1463
|
-
#### Returns
|
|
1464
|
-
|
|
1465
|
-
`AsyncIterableIterator`<`any`\>
|
|
1466
|
-
|
|
1467
|
-
that iterates `eventName` events emitted by the `emitter`
|
|
1468
|
-
|
|
1469
|
-
#### Inherited from
|
|
1470
|
-
|
|
1471
|
-
EventEmitter.on
|
|
1472
|
-
|
|
1473
|
-
#### Defined in
|
|
1474
|
-
|
|
1475
|
-
node_modules/@types/node/events.d.ts:254
|
|
1476
|
-
|
|
1477
|
-
___
|
|
1478
|
-
|
|
1479
|
-
### once
|
|
1480
|
-
|
|
1481
|
-
▸ `Static` **once**(`emitter`, `eventName`, `options?`): `Promise`<`any`[]\>
|
|
1482
|
-
|
|
1483
|
-
Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
|
|
1484
|
-
event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
|
|
1485
|
-
The `Promise` will resolve with an array of all the arguments emitted to the
|
|
1486
|
-
given event.
|
|
1487
|
-
|
|
1488
|
-
This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event
|
|
1489
|
-
semantics and does not listen to the `'error'` event.
|
|
1490
|
-
|
|
1491
|
-
```js
|
|
1492
|
-
const { once, EventEmitter } = require('events');
|
|
1493
|
-
|
|
1494
|
-
async function run() {
|
|
1495
|
-
const ee = new EventEmitter();
|
|
1496
|
-
|
|
1497
|
-
process.nextTick(() => {
|
|
1498
|
-
ee.emit('myevent', 42);
|
|
1499
|
-
});
|
|
1500
|
-
|
|
1501
|
-
const [value] = await once(ee, 'myevent');
|
|
1502
|
-
console.log(value);
|
|
1503
|
-
|
|
1504
|
-
const err = new Error('kaboom');
|
|
1505
|
-
process.nextTick(() => {
|
|
1506
|
-
ee.emit('error', err);
|
|
1507
|
-
});
|
|
1508
|
-
|
|
1509
|
-
try {
|
|
1510
|
-
await once(ee, 'myevent');
|
|
1511
|
-
} catch (err) {
|
|
1512
|
-
console.log('error happened', err);
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
|
-
run();
|
|
1517
|
-
```
|
|
1518
|
-
|
|
1519
|
-
The special handling of the `'error'` event is only used when `events.once()`is used to wait for another event. If `events.once()` is used to wait for the
|
|
1520
|
-
'`error'` event itself, then it is treated as any other kind of event without
|
|
1521
|
-
special handling:
|
|
1522
|
-
|
|
1523
|
-
```js
|
|
1524
|
-
const { EventEmitter, once } = require('events');
|
|
1525
|
-
|
|
1526
|
-
const ee = new EventEmitter();
|
|
1527
|
-
|
|
1528
|
-
once(ee, 'error')
|
|
1529
|
-
.then(([err]) => console.log('ok', err.message))
|
|
1530
|
-
.catch((err) => console.log('error', err.message));
|
|
1531
|
-
|
|
1532
|
-
ee.emit('error', new Error('boom'));
|
|
1533
|
-
|
|
1534
|
-
// Prints: ok boom
|
|
1535
|
-
```
|
|
1536
|
-
|
|
1537
|
-
An `AbortSignal` can be used to cancel waiting for the event:
|
|
1538
|
-
|
|
1539
|
-
```js
|
|
1540
|
-
const { EventEmitter, once } = require('events');
|
|
1541
|
-
|
|
1542
|
-
const ee = new EventEmitter();
|
|
1543
|
-
const ac = new AbortController();
|
|
1544
|
-
|
|
1545
|
-
async function foo(emitter, event, signal) {
|
|
1546
|
-
try {
|
|
1547
|
-
await once(emitter, event, { signal });
|
|
1548
|
-
console.log('event emitted!');
|
|
1549
|
-
} catch (error) {
|
|
1550
|
-
if (error.name === 'AbortError') {
|
|
1551
|
-
console.error('Waiting for the event was canceled!');
|
|
1552
|
-
} else {
|
|
1553
|
-
console.error('There was an error', error.message);
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
|
-
foo(ee, 'foo', ac.signal);
|
|
1559
|
-
ac.abort(); // Abort waiting for the event
|
|
1560
|
-
ee.emit('foo'); // Prints: Waiting for the event was canceled!
|
|
1561
|
-
```
|
|
1562
|
-
|
|
1563
|
-
**`Since`**
|
|
1564
|
-
|
|
1565
|
-
v11.13.0, v10.16.0
|
|
1566
|
-
|
|
1567
|
-
#### Parameters
|
|
1568
|
-
|
|
1569
|
-
| Name | Type |
|
|
1570
|
-
| :------ | :------ |
|
|
1571
|
-
| `emitter` | `_NodeEventTarget` |
|
|
1572
|
-
| `eventName` | `string` \| `symbol` |
|
|
1573
|
-
| `options?` | `StaticEventEmitterOptions` |
|
|
1574
|
-
|
|
1575
|
-
#### Returns
|
|
1576
|
-
|
|
1577
|
-
`Promise`<`any`[]\>
|
|
1578
|
-
|
|
1579
|
-
#### Inherited from
|
|
1580
|
-
|
|
1581
|
-
EventEmitter.once
|
|
1582
|
-
|
|
1583
|
-
#### Defined in
|
|
1584
|
-
|
|
1585
|
-
node_modules/@types/node/events.d.ts:194
|
|
1586
|
-
|
|
1587
|
-
▸ `Static` **once**(`emitter`, `eventName`, `options?`): `Promise`<`any`[]\>
|
|
1588
|
-
|
|
1589
|
-
#### Parameters
|
|
1590
|
-
|
|
1591
|
-
| Name | Type |
|
|
1592
|
-
| :------ | :------ |
|
|
1593
|
-
| `emitter` | `_DOMEventTarget` |
|
|
1594
|
-
| `eventName` | `string` |
|
|
1595
|
-
| `options?` | `StaticEventEmitterOptions` |
|
|
1596
|
-
|
|
1597
|
-
#### Returns
|
|
1598
|
-
|
|
1599
|
-
`Promise`<`any`[]\>
|
|
1600
|
-
|
|
1601
|
-
#### Inherited from
|
|
1602
|
-
|
|
1603
|
-
EventEmitter.once
|
|
1604
|
-
|
|
1605
|
-
#### Defined in
|
|
1606
|
-
|
|
1607
|
-
node_modules/@types/node/events.d.ts:195
|
|
1608
|
-
|
|
1609
|
-
___
|
|
1610
|
-
|
|
1611
|
-
### setMaxListeners
|
|
1612
|
-
|
|
1613
|
-
▸ `Static` **setMaxListeners**(`n?`, `...eventTargets`): `void`
|
|
1614
|
-
|
|
1615
|
-
```js
|
|
1616
|
-
const {
|
|
1617
|
-
setMaxListeners,
|
|
1618
|
-
EventEmitter
|
|
1619
|
-
} = require('events');
|
|
1620
|
-
|
|
1621
|
-
const target = new EventTarget();
|
|
1622
|
-
const emitter = new EventEmitter();
|
|
1623
|
-
|
|
1624
|
-
setMaxListeners(5, target, emitter);
|
|
1625
|
-
```
|
|
1626
|
-
|
|
1627
|
-
**`Since`**
|
|
1628
|
-
|
|
1629
|
-
v15.4.0
|
|
1630
|
-
|
|
1631
|
-
#### Parameters
|
|
1632
|
-
|
|
1633
|
-
| Name | Type | Description |
|
|
1634
|
-
| :------ | :------ | :------ |
|
|
1635
|
-
| `n?` | `number` | A non-negative number. The maximum number of listeners per `EventTarget` event. |
|
|
1636
|
-
| `...eventTargets` | (`EventEmitter` \| `_DOMEventTarget`)[] | - |
|
|
1637
|
-
|
|
1638
|
-
#### Returns
|
|
1639
|
-
|
|
1640
|
-
`void`
|
|
1641
|
-
|
|
1642
|
-
#### Inherited from
|
|
1643
|
-
|
|
1644
|
-
EventEmitter.setMaxListeners
|
|
1645
|
-
|
|
1646
|
-
#### Defined in
|
|
1647
|
-
|
|
1648
|
-
node_modules/@types/node/events.d.ts:317
|