@rapidrest/service-core 1.0.0-beta.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/LICENSE +23 -0
- package/README.md +16 -0
- package/dist/lib/ApiErrors.js +41 -0
- package/dist/lib/ApiErrors.js.map +1 -0
- package/dist/lib/BackgroundService.js +16 -0
- package/dist/lib/BackgroundService.js.map +1 -0
- package/dist/lib/BackgroundServiceManager.js +135 -0
- package/dist/lib/BackgroundServiceManager.js.map +1 -0
- package/dist/lib/BulkError.js +24 -0
- package/dist/lib/BulkError.js.map +1 -0
- package/dist/lib/EventListenerManager.js +161 -0
- package/dist/lib/EventListenerManager.js.map +1 -0
- package/dist/lib/NetUtils.js +103 -0
- package/dist/lib/NetUtils.js.map +1 -0
- package/dist/lib/NotificationUtils.js +34 -0
- package/dist/lib/NotificationUtils.js.map +1 -0
- package/dist/lib/ObjectFactory.js +90 -0
- package/dist/lib/ObjectFactory.js.map +1 -0
- package/dist/lib/OpenApiSpec.js +748 -0
- package/dist/lib/OpenApiSpec.js.map +1 -0
- package/dist/lib/Server.js +549 -0
- package/dist/lib/Server.js.map +1 -0
- package/dist/lib/Types.js +2 -0
- package/dist/lib/Types.js.map +1 -0
- package/dist/lib/auth/AuthMiddleware.js +229 -0
- package/dist/lib/auth/AuthMiddleware.js.map +1 -0
- package/dist/lib/auth/AuthStrategy.js +2 -0
- package/dist/lib/auth/AuthStrategy.js.map +1 -0
- package/dist/lib/auth/BasicStrategy.js +106 -0
- package/dist/lib/auth/BasicStrategy.js.map +1 -0
- package/dist/lib/auth/JWTStrategy.js +161 -0
- package/dist/lib/auth/JWTStrategy.js.map +1 -0
- package/dist/lib/auth/index.js +5 -0
- package/dist/lib/auth/index.js.map +1 -0
- package/dist/lib/database/ConnectionKinds.js +14 -0
- package/dist/lib/database/ConnectionKinds.js.map +1 -0
- package/dist/lib/database/ConnectionManager.js +161 -0
- package/dist/lib/database/ConnectionManager.js.map +1 -0
- package/dist/lib/database/MongoConnection.js +86 -0
- package/dist/lib/database/MongoConnection.js.map +1 -0
- package/dist/lib/database/MongoRepository.js +136 -0
- package/dist/lib/database/MongoRepository.js.map +1 -0
- package/dist/lib/database/MongoSchemaSync.js +136 -0
- package/dist/lib/database/MongoSchemaSync.js.map +1 -0
- package/dist/lib/database/NamingUtils.js +52 -0
- package/dist/lib/database/NamingUtils.js.map +1 -0
- package/dist/lib/database/TypeOrmSupport.js +146 -0
- package/dist/lib/database/TypeOrmSupport.js.map +1 -0
- package/dist/lib/database/index.js +7 -0
- package/dist/lib/database/index.js.map +1 -0
- package/dist/lib/decorators/DatabaseDecorators.js +52 -0
- package/dist/lib/decorators/DatabaseDecorators.js.map +1 -0
- package/dist/lib/decorators/DocDecorators.js +120 -0
- package/dist/lib/decorators/DocDecorators.js.map +1 -0
- package/dist/lib/decorators/EventDecorators.js +24 -0
- package/dist/lib/decorators/EventDecorators.js.map +1 -0
- package/dist/lib/decorators/ModelDecorators.js +173 -0
- package/dist/lib/decorators/ModelDecorators.js.map +1 -0
- package/dist/lib/decorators/PersistenceDecorators.js +177 -0
- package/dist/lib/decorators/PersistenceDecorators.js.map +1 -0
- package/dist/lib/decorators/RouteDecorators.js +324 -0
- package/dist/lib/decorators/RouteDecorators.js.map +1 -0
- package/dist/lib/decorators/index.js +7 -0
- package/dist/lib/decorators/index.js.map +1 -0
- package/dist/lib/http/Adapters.js +230 -0
- package/dist/lib/http/Adapters.js.map +1 -0
- package/dist/lib/http/Router.js +403 -0
- package/dist/lib/http/Router.js.map +1 -0
- package/dist/lib/http/WebSocket.js +82 -0
- package/dist/lib/http/WebSocket.js.map +1 -0
- package/dist/lib/http/index.js +4 -0
- package/dist/lib/http/index.js.map +1 -0
- package/dist/lib/http/types.js +5 -0
- package/dist/lib/http/types.js.map +1 -0
- package/dist/lib/index.js +18 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/models/BaseEntity.js +83 -0
- package/dist/lib/models/BaseEntity.js.map +1 -0
- package/dist/lib/models/BaseMongoEntity.js +40 -0
- package/dist/lib/models/BaseMongoEntity.js.map +1 -0
- package/dist/lib/models/ModelUtils.js +645 -0
- package/dist/lib/models/ModelUtils.js.map +1 -0
- package/dist/lib/models/RecoverableBaseEntity.js +39 -0
- package/dist/lib/models/RecoverableBaseEntity.js.map +1 -0
- package/dist/lib/models/RecoverableBaseMongoEntity.js +40 -0
- package/dist/lib/models/RecoverableBaseMongoEntity.js.map +1 -0
- package/dist/lib/models/RepoUtils.js +717 -0
- package/dist/lib/models/RepoUtils.js.map +1 -0
- package/dist/lib/models/SimpleEntity.js +42 -0
- package/dist/lib/models/SimpleEntity.js.map +1 -0
- package/dist/lib/models/SimpleMongoEntity.js +38 -0
- package/dist/lib/models/SimpleMongoEntity.js.map +1 -0
- package/dist/lib/models/StatusExtraData.js +15 -0
- package/dist/lib/models/StatusExtraData.js.map +1 -0
- package/dist/lib/models/index.js +10 -0
- package/dist/lib/models/index.js.map +1 -0
- package/dist/lib/routes/AdminRoute.js +268 -0
- package/dist/lib/routes/AdminRoute.js.map +1 -0
- package/dist/lib/routes/MetricsRoute.js +86 -0
- package/dist/lib/routes/MetricsRoute.js.map +1 -0
- package/dist/lib/routes/ModelRoute.js +481 -0
- package/dist/lib/routes/ModelRoute.js.map +1 -0
- package/dist/lib/routes/OpenAPIRoute.js +115 -0
- package/dist/lib/routes/OpenAPIRoute.js.map +1 -0
- package/dist/lib/routes/RouteUtils.js +445 -0
- package/dist/lib/routes/RouteUtils.js.map +1 -0
- package/dist/lib/routes/StatusRoute.js +55 -0
- package/dist/lib/routes/StatusRoute.js.map +1 -0
- package/dist/lib/routes/index.js +7 -0
- package/dist/lib/routes/index.js.map +1 -0
- package/dist/lib/security/ACLRouteMongo.js +194 -0
- package/dist/lib/security/ACLRouteMongo.js.map +1 -0
- package/dist/lib/security/ACLRouteSQL.js +193 -0
- package/dist/lib/security/ACLRouteSQL.js.map +1 -0
- package/dist/lib/security/ACLUtils.js +457 -0
- package/dist/lib/security/ACLUtils.js.map +1 -0
- package/dist/lib/security/AccessControlList.js +18 -0
- package/dist/lib/security/AccessControlList.js.map +1 -0
- package/dist/lib/security/AccessControlListMongo.js +155 -0
- package/dist/lib/security/AccessControlListMongo.js.map +1 -0
- package/dist/lib/security/AccessControlListSQL.js +149 -0
- package/dist/lib/security/AccessControlListSQL.js.map +1 -0
- package/dist/lib/security/index.js +3 -0
- package/dist/lib/security/index.js.map +1 -0
- package/dist/lib/test/index.js +3 -0
- package/dist/lib/test/index.js.map +1 -0
- package/dist/lib/test/request.js +99 -0
- package/dist/lib/test/request.js.map +1 -0
- package/dist/lib/test/requestws.js +173 -0
- package/dist/lib/test/requestws.js.map +1 -0
- package/dist/types/ApiErrors.d.ts +38 -0
- package/dist/types/BackgroundService.d.ts +30 -0
- package/dist/types/BackgroundServiceManager.d.ts +66 -0
- package/dist/types/BulkError.d.ts +11 -0
- package/dist/types/EventListenerManager.d.ts +36 -0
- package/dist/types/NetUtils.d.ts +29 -0
- package/dist/types/NotificationUtils.d.ts +25 -0
- package/dist/types/ObjectFactory.d.ts +17 -0
- package/dist/types/OpenApiSpec.d.ts +114 -0
- package/dist/types/Server.d.ts +180 -0
- package/dist/types/Types.d.ts +8 -0
- package/dist/types/auth/AuthMiddleware.d.ts +42 -0
- package/dist/types/auth/AuthStrategy.d.ts +32 -0
- package/dist/types/auth/BasicStrategy.d.ts +33 -0
- package/dist/types/auth/JWTStrategy.d.ts +61 -0
- package/dist/types/auth/index.d.ts +4 -0
- package/dist/types/database/ConnectionKinds.d.ts +7 -0
- package/dist/types/database/ConnectionManager.d.ts +35 -0
- package/dist/types/database/MongoConnection.d.ts +54 -0
- package/dist/types/database/MongoRepository.d.ts +92 -0
- package/dist/types/database/MongoSchemaSync.d.ts +41 -0
- package/dist/types/database/NamingUtils.d.ts +24 -0
- package/dist/types/database/TypeOrmSupport.d.ts +20 -0
- package/dist/types/database/index.d.ts +6 -0
- package/dist/types/decorators/DatabaseDecorators.d.ts +18 -0
- package/dist/types/decorators/DocDecorators.d.ts +69 -0
- package/dist/types/decorators/EventDecorators.d.ts +12 -0
- package/dist/types/decorators/ModelDecorators.d.ts +80 -0
- package/dist/types/decorators/PersistenceDecorators.d.ts +117 -0
- package/dist/types/decorators/RouteDecorators.d.ts +172 -0
- package/dist/types/decorators/index.d.ts +6 -0
- package/dist/types/http/Adapters.d.ts +68 -0
- package/dist/types/http/Router.d.ts +99 -0
- package/dist/types/http/WebSocket.d.ts +56 -0
- package/dist/types/http/index.d.ts +6 -0
- package/dist/types/http/types.d.ts +54 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/models/BaseEntity.d.ts +29 -0
- package/dist/types/models/BaseMongoEntity.d.ts +13 -0
- package/dist/types/models/ModelUtils.d.ts +166 -0
- package/dist/types/models/RecoverableBaseEntity.d.ts +16 -0
- package/dist/types/models/RecoverableBaseMongoEntity.d.ts +16 -0
- package/dist/types/models/RepoUtils.d.ts +154 -0
- package/dist/types/models/SimpleEntity.d.ts +14 -0
- package/dist/types/models/SimpleMongoEntity.d.ts +15 -0
- package/dist/types/models/StatusExtraData.d.ts +6 -0
- package/dist/types/models/index.d.ts +9 -0
- package/dist/types/routes/AdminRoute.d.ts +47 -0
- package/dist/types/routes/MetricsRoute.d.ts +15 -0
- package/dist/types/routes/ModelRoute.d.ts +226 -0
- package/dist/types/routes/OpenAPIRoute.d.ts +17 -0
- package/dist/types/routes/RouteUtils.d.ts +55 -0
- package/dist/types/routes/StatusRoute.d.ts +11 -0
- package/dist/types/routes/index.d.ts +6 -0
- package/dist/types/security/ACLRouteMongo.d.ts +19 -0
- package/dist/types/security/ACLRouteSQL.d.ts +19 -0
- package/dist/types/security/ACLUtils.d.ts +94 -0
- package/dist/types/security/AccessControlList.d.ts +103 -0
- package/dist/types/security/AccessControlListMongo.d.ts +24 -0
- package/dist/types/security/AccessControlListSQL.d.ts +24 -0
- package/dist/types/security/index.d.ts +2 -0
- package/dist/types/test/index.d.ts +2 -0
- package/dist/types/test/request.d.ts +24 -0
- package/dist/types/test/requestws.d.ts +21 -0
- package/docs/Makefile +20 -0
- package/docs/conf.py +58 -0
- package/docs/index.rst +17 -0
- package/docs/make.bat +35 -0
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/README.md +13 -0
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/MongoRepository.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/RedisConnection.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/Repository.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/README.md +23 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Default.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Description.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Document.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Example.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Format.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Returns.md +28 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Summary.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Tags.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/TypeInfo.md +28 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/interfaces/DocumentsData.md +57 -0
- package/docs/reference/@rapidrest/namespaces/EventDecorators/README.md +12 -0
- package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/EventListener.md +17 -0
- package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/OnEvent.md +26 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/README.md +26 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Cache.md +25 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/ChildEntity.md +18 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/DataStore.md +25 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Identifier.md +27 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Protect.md +35 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Reference.md +25 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Shard.md +27 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/TrackChanges.md +26 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/interfaces/PendingTypeOrmColumn.md +45 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/variables/pendingTypeOrmColumns.md +14 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/README.md +25 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Column.md +25 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Entity.md +26 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Index.md +119 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/PrimaryColumn.md +25 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Unique.md +68 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getColumnMetadata.md +26 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getEntityName.md +26 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getIndexMetadata.md +27 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnInfo.md +41 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnOptions.md +51 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexInfo.md +41 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexOptions.md +51 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/README.md +36 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/After.md +26 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Auth.md +33 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/AuthResult.md +31 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Before.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/ContentType.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Delete.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Get.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Head.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Header.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Method.md +31 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Model.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Options.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Param.md +26 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Patch.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Post.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Protect.md +31 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Put.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Query.md +26 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Request.md +31 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/RequiresRole.md +26 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Response.md +31 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Route.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Socket.md +33 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/User.md +31 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Validate.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/WebSocket.md +25 -0
- package/docs/reference/README.md +20 -0
- package/docs/reference/classes/ACLUtils.md +251 -0
- package/docs/reference/classes/AdminRoute.md +51 -0
- package/docs/reference/classes/AuthMiddleware.md +131 -0
- package/docs/reference/classes/BackgroundService.md +117 -0
- package/docs/reference/classes/BackgroundServiceManager.md +172 -0
- package/docs/reference/classes/BaseEntity.md +82 -0
- package/docs/reference/classes/BaseMongoEntity.md +107 -0
- package/docs/reference/classes/BasicStrategy.md +89 -0
- package/docs/reference/classes/BasicStrategyOptions.md +91 -0
- package/docs/reference/classes/BulkError.md +271 -0
- package/docs/reference/classes/ConnectionManager.md +75 -0
- package/docs/reference/classes/EventListenerManager.md +88 -0
- package/docs/reference/classes/JWTStrategy.md +77 -0
- package/docs/reference/classes/JWTStrategyOptions.md +97 -0
- package/docs/reference/classes/MetricsRoute.md +27 -0
- package/docs/reference/classes/ModelRoute.md +527 -0
- package/docs/reference/classes/ModelUtils.md +448 -0
- package/docs/reference/classes/MongoConnection.md +218 -0
- package/docs/reference/classes/MongoRepository.md +354 -0
- package/docs/reference/classes/MongoSchemaSync.md +67 -0
- package/docs/reference/classes/NetUtils.md +90 -0
- package/docs/reference/classes/NotificationUtils.md +77 -0
- package/docs/reference/classes/ObjectFactory.md +336 -0
- package/docs/reference/classes/OpenAPIRoute.md +77 -0
- package/docs/reference/classes/OpenApiSpec.md +892 -0
- package/docs/reference/classes/RecoverableBaseEntity.md +114 -0
- package/docs/reference/classes/RecoverableBaseMongoEntity.md +124 -0
- package/docs/reference/classes/RedisTransport.md +2202 -0
- package/docs/reference/classes/RepoUtils.md +486 -0
- package/docs/reference/classes/RouteUtils.md +191 -0
- package/docs/reference/classes/Server.md +408 -0
- package/docs/reference/classes/SimpleEntity.md +48 -0
- package/docs/reference/classes/SimpleMongoEntity.md +66 -0
- package/docs/reference/classes/StatusExtraData.md +57 -0
- package/docs/reference/classes/StatusRoute.md +26 -0
- package/docs/reference/enumerations/ACLAction.md +63 -0
- package/docs/reference/enumerations/ApiErrorMessages.md +123 -0
- package/docs/reference/enumerations/ApiErrors.md +123 -0
- package/docs/reference/functions/isSqlDataSource.md +26 -0
- package/docs/reference/functions/resolveCollectionName.md +33 -0
- package/docs/reference/functions/snakeCase.md +28 -0
- package/docs/reference/globals.md +91 -0
- package/docs/reference/interfaces/ACLRecord.md +96 -0
- package/docs/reference/interfaces/AccessControlList.md +76 -0
- package/docs/reference/interfaces/AuthResult.md +55 -0
- package/docs/reference/interfaces/AuthStrategy.md +57 -0
- package/docs/reference/interfaces/CreateRequestOptions.md +121 -0
- package/docs/reference/interfaces/DeleteRequestOptions.md +147 -0
- package/docs/reference/interfaces/FindRequestOptions.md +133 -0
- package/docs/reference/interfaces/JWTAuthResult.md +84 -0
- package/docs/reference/interfaces/RepoCreateOptions.md +95 -0
- package/docs/reference/interfaces/RepoDeleteOptions.md +115 -0
- package/docs/reference/interfaces/RepoFindOptions.md +135 -0
- package/docs/reference/interfaces/RepoOperationOptions.md +69 -0
- package/docs/reference/interfaces/RepoUpdateOptions.md +111 -0
- package/docs/reference/interfaces/RequestOptions.md +112 -0
- package/docs/reference/interfaces/TruncateRequestOptions.md +175 -0
- package/docs/reference/interfaces/UpdateRequestOptions.md +149 -0
- package/docs/reference/type-aliases/OneOrMany.md +19 -0
- package/docs/reference/type-aliases/OneOrNull.md +19 -0
- package/docs/reference/type-aliases/PartialBaseEntity.md +17 -0
- package/docs/reference/type-aliases/PartialSimpleEntity.md +17 -0
- package/docs/reference/type-aliases/UpdateObject.md +19 -0
- package/package.json +125 -0
|
@@ -0,0 +1,2202 @@
|
|
|
1
|
+
[**@rapidrest/service-core**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@rapidrest/service-core](../globals.md) / RedisTransport
|
|
6
|
+
|
|
7
|
+
# Class: RedisTransport
|
|
8
|
+
|
|
9
|
+
Defined in: [src/routes/AdminRoute.ts:17](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/routes/AdminRoute.ts#L17)
|
|
10
|
+
|
|
11
|
+
Implements a Winston transport that pipes incoming log messages to a configured redis pubsub channel.
|
|
12
|
+
|
|
13
|
+
## Extends
|
|
14
|
+
|
|
15
|
+
- `TransportStream`
|
|
16
|
+
|
|
17
|
+
## Constructors
|
|
18
|
+
|
|
19
|
+
### Constructor
|
|
20
|
+
|
|
21
|
+
> **new RedisTransport**(`opts`): `RedisTransport`
|
|
22
|
+
|
|
23
|
+
Defined in: [src/routes/AdminRoute.ts:21](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/routes/AdminRoute.ts#L21)
|
|
24
|
+
|
|
25
|
+
#### Parameters
|
|
26
|
+
|
|
27
|
+
##### opts
|
|
28
|
+
|
|
29
|
+
`any`
|
|
30
|
+
|
|
31
|
+
#### Returns
|
|
32
|
+
|
|
33
|
+
`RedisTransport`
|
|
34
|
+
|
|
35
|
+
#### Overrides
|
|
36
|
+
|
|
37
|
+
`Transport.constructor`
|
|
38
|
+
|
|
39
|
+
## Properties
|
|
40
|
+
|
|
41
|
+
### closed
|
|
42
|
+
|
|
43
|
+
> `readonly` **closed**: `boolean`
|
|
44
|
+
|
|
45
|
+
Defined in: node\_modules/@types/node/stream.d.ts:809
|
|
46
|
+
|
|
47
|
+
Is `true` after `'close'` has been emitted.
|
|
48
|
+
|
|
49
|
+
#### Since
|
|
50
|
+
|
|
51
|
+
v18.0.0
|
|
52
|
+
|
|
53
|
+
#### Inherited from
|
|
54
|
+
|
|
55
|
+
`Transport.closed`
|
|
56
|
+
|
|
57
|
+
***
|
|
58
|
+
|
|
59
|
+
### destroyed
|
|
60
|
+
|
|
61
|
+
> **destroyed**: `boolean`
|
|
62
|
+
|
|
63
|
+
Defined in: node\_modules/@types/node/stream.d.ts:804
|
|
64
|
+
|
|
65
|
+
Is `true` after `writable.destroy()` has been called.
|
|
66
|
+
|
|
67
|
+
#### Since
|
|
68
|
+
|
|
69
|
+
v8.0.0
|
|
70
|
+
|
|
71
|
+
#### Inherited from
|
|
72
|
+
|
|
73
|
+
`Transport.destroyed`
|
|
74
|
+
|
|
75
|
+
***
|
|
76
|
+
|
|
77
|
+
### errored
|
|
78
|
+
|
|
79
|
+
> `readonly` **errored**: `Error` \| `null`
|
|
80
|
+
|
|
81
|
+
Defined in: node\_modules/@types/node/stream.d.ts:814
|
|
82
|
+
|
|
83
|
+
Returns error if the stream has been destroyed with an error.
|
|
84
|
+
|
|
85
|
+
#### Since
|
|
86
|
+
|
|
87
|
+
v18.0.0
|
|
88
|
+
|
|
89
|
+
#### Inherited from
|
|
90
|
+
|
|
91
|
+
`Transport.errored`
|
|
92
|
+
|
|
93
|
+
***
|
|
94
|
+
|
|
95
|
+
### format?
|
|
96
|
+
|
|
97
|
+
> `optional` **format?**: `Format`
|
|
98
|
+
|
|
99
|
+
Defined in: node\_modules/winston-transport/index.d.ts:12
|
|
100
|
+
|
|
101
|
+
#### Inherited from
|
|
102
|
+
|
|
103
|
+
`Transport.format`
|
|
104
|
+
|
|
105
|
+
***
|
|
106
|
+
|
|
107
|
+
### handleExceptions?
|
|
108
|
+
|
|
109
|
+
> `optional` **handleExceptions?**: `boolean`
|
|
110
|
+
|
|
111
|
+
Defined in: node\_modules/winston-transport/index.d.ts:15
|
|
112
|
+
|
|
113
|
+
#### Inherited from
|
|
114
|
+
|
|
115
|
+
`Transport.handleExceptions`
|
|
116
|
+
|
|
117
|
+
***
|
|
118
|
+
|
|
119
|
+
### handleRejections?
|
|
120
|
+
|
|
121
|
+
> `optional` **handleRejections?**: `boolean`
|
|
122
|
+
|
|
123
|
+
Defined in: node\_modules/winston-transport/index.d.ts:16
|
|
124
|
+
|
|
125
|
+
#### Inherited from
|
|
126
|
+
|
|
127
|
+
`Transport.handleRejections`
|
|
128
|
+
|
|
129
|
+
***
|
|
130
|
+
|
|
131
|
+
### level?
|
|
132
|
+
|
|
133
|
+
> `optional` **level?**: `string`
|
|
134
|
+
|
|
135
|
+
Defined in: node\_modules/winston-transport/index.d.ts:13
|
|
136
|
+
|
|
137
|
+
#### Inherited from
|
|
138
|
+
|
|
139
|
+
`Transport.level`
|
|
140
|
+
|
|
141
|
+
***
|
|
142
|
+
|
|
143
|
+
### silent?
|
|
144
|
+
|
|
145
|
+
> `optional` **silent?**: `boolean`
|
|
146
|
+
|
|
147
|
+
Defined in: node\_modules/winston-transport/index.d.ts:14
|
|
148
|
+
|
|
149
|
+
#### Inherited from
|
|
150
|
+
|
|
151
|
+
`Transport.silent`
|
|
152
|
+
|
|
153
|
+
***
|
|
154
|
+
|
|
155
|
+
### writable
|
|
156
|
+
|
|
157
|
+
> **writable**: `boolean`
|
|
158
|
+
|
|
159
|
+
Defined in: node\_modules/@types/node/stream.d.ts:760
|
|
160
|
+
|
|
161
|
+
Is `true` if it is safe to call `writable.write()`, which means
|
|
162
|
+
the stream has not been destroyed, errored, or ended.
|
|
163
|
+
|
|
164
|
+
#### Since
|
|
165
|
+
|
|
166
|
+
v11.4.0
|
|
167
|
+
|
|
168
|
+
#### Inherited from
|
|
169
|
+
|
|
170
|
+
`Transport.writable`
|
|
171
|
+
|
|
172
|
+
***
|
|
173
|
+
|
|
174
|
+
### writableAborted
|
|
175
|
+
|
|
176
|
+
> `readonly` **writableAborted**: `boolean`
|
|
177
|
+
|
|
178
|
+
Defined in: node\_modules/@types/node/stream.d.ts:765
|
|
179
|
+
|
|
180
|
+
Returns whether the stream was destroyed or errored before emitting `'finish'`.
|
|
181
|
+
|
|
182
|
+
#### Since
|
|
183
|
+
|
|
184
|
+
v18.0.0, v16.17.0
|
|
185
|
+
|
|
186
|
+
#### Inherited from
|
|
187
|
+
|
|
188
|
+
`Transport.writableAborted`
|
|
189
|
+
|
|
190
|
+
***
|
|
191
|
+
|
|
192
|
+
### writableCorked
|
|
193
|
+
|
|
194
|
+
> `readonly` **writableCorked**: `number`
|
|
195
|
+
|
|
196
|
+
Defined in: node\_modules/@types/node/stream.d.ts:799
|
|
197
|
+
|
|
198
|
+
Number of times `writable.uncork()` needs to be
|
|
199
|
+
called in order to fully uncork the stream.
|
|
200
|
+
|
|
201
|
+
#### Since
|
|
202
|
+
|
|
203
|
+
v13.2.0, v12.16.0
|
|
204
|
+
|
|
205
|
+
#### Inherited from
|
|
206
|
+
|
|
207
|
+
`Transport.writableCorked`
|
|
208
|
+
|
|
209
|
+
***
|
|
210
|
+
|
|
211
|
+
### writableEnded
|
|
212
|
+
|
|
213
|
+
> `readonly` **writableEnded**: `boolean`
|
|
214
|
+
|
|
215
|
+
Defined in: node\_modules/@types/node/stream.d.ts:771
|
|
216
|
+
|
|
217
|
+
Is `true` after `writable.end()` has been called. This property
|
|
218
|
+
does not indicate whether the data has been flushed, for this use `writable.writableFinished` instead.
|
|
219
|
+
|
|
220
|
+
#### Since
|
|
221
|
+
|
|
222
|
+
v12.9.0
|
|
223
|
+
|
|
224
|
+
#### Inherited from
|
|
225
|
+
|
|
226
|
+
`Transport.writableEnded`
|
|
227
|
+
|
|
228
|
+
***
|
|
229
|
+
|
|
230
|
+
### writableFinished
|
|
231
|
+
|
|
232
|
+
> `readonly` **writableFinished**: `boolean`
|
|
233
|
+
|
|
234
|
+
Defined in: node\_modules/@types/node/stream.d.ts:776
|
|
235
|
+
|
|
236
|
+
Is set to `true` immediately before the `'finish'` event is emitted.
|
|
237
|
+
|
|
238
|
+
#### Since
|
|
239
|
+
|
|
240
|
+
v12.6.0
|
|
241
|
+
|
|
242
|
+
#### Inherited from
|
|
243
|
+
|
|
244
|
+
`Transport.writableFinished`
|
|
245
|
+
|
|
246
|
+
***
|
|
247
|
+
|
|
248
|
+
### writableHighWaterMark
|
|
249
|
+
|
|
250
|
+
> `readonly` **writableHighWaterMark**: `number`
|
|
251
|
+
|
|
252
|
+
Defined in: node\_modules/@types/node/stream.d.ts:781
|
|
253
|
+
|
|
254
|
+
Return the value of `highWaterMark` passed when creating this `Writable`.
|
|
255
|
+
|
|
256
|
+
#### Since
|
|
257
|
+
|
|
258
|
+
v9.3.0
|
|
259
|
+
|
|
260
|
+
#### Inherited from
|
|
261
|
+
|
|
262
|
+
`Transport.writableHighWaterMark`
|
|
263
|
+
|
|
264
|
+
***
|
|
265
|
+
|
|
266
|
+
### writableLength
|
|
267
|
+
|
|
268
|
+
> `readonly` **writableLength**: `number`
|
|
269
|
+
|
|
270
|
+
Defined in: node\_modules/@types/node/stream.d.ts:788
|
|
271
|
+
|
|
272
|
+
This property contains the number of bytes (or objects) in the queue
|
|
273
|
+
ready to be written. The value provides introspection data regarding
|
|
274
|
+
the status of the `highWaterMark`.
|
|
275
|
+
|
|
276
|
+
#### Since
|
|
277
|
+
|
|
278
|
+
v9.4.0
|
|
279
|
+
|
|
280
|
+
#### Inherited from
|
|
281
|
+
|
|
282
|
+
`Transport.writableLength`
|
|
283
|
+
|
|
284
|
+
***
|
|
285
|
+
|
|
286
|
+
### writableNeedDrain
|
|
287
|
+
|
|
288
|
+
> `readonly` **writableNeedDrain**: `boolean`
|
|
289
|
+
|
|
290
|
+
Defined in: node\_modules/@types/node/stream.d.ts:819
|
|
291
|
+
|
|
292
|
+
Is `true` if the stream's buffer has been full and stream will emit `'drain'`.
|
|
293
|
+
|
|
294
|
+
#### Since
|
|
295
|
+
|
|
296
|
+
v15.2.0, v14.17.0
|
|
297
|
+
|
|
298
|
+
#### Inherited from
|
|
299
|
+
|
|
300
|
+
`Transport.writableNeedDrain`
|
|
301
|
+
|
|
302
|
+
***
|
|
303
|
+
|
|
304
|
+
### writableObjectMode
|
|
305
|
+
|
|
306
|
+
> `readonly` **writableObjectMode**: `boolean`
|
|
307
|
+
|
|
308
|
+
Defined in: node\_modules/@types/node/stream.d.ts:793
|
|
309
|
+
|
|
310
|
+
Getter for the property `objectMode` of a given `Writable` stream.
|
|
311
|
+
|
|
312
|
+
#### Since
|
|
313
|
+
|
|
314
|
+
v12.3.0
|
|
315
|
+
|
|
316
|
+
#### Inherited from
|
|
317
|
+
|
|
318
|
+
`Transport.writableObjectMode`
|
|
319
|
+
|
|
320
|
+
## Methods
|
|
321
|
+
|
|
322
|
+
### \_construct()?
|
|
323
|
+
|
|
324
|
+
> `optional` **\_construct**(`callback`): `void`
|
|
325
|
+
|
|
326
|
+
Defined in: node\_modules/@types/node/stream.d.ts:828
|
|
327
|
+
|
|
328
|
+
#### Parameters
|
|
329
|
+
|
|
330
|
+
##### callback
|
|
331
|
+
|
|
332
|
+
(`error?`) => `void`
|
|
333
|
+
|
|
334
|
+
#### Returns
|
|
335
|
+
|
|
336
|
+
`void`
|
|
337
|
+
|
|
338
|
+
#### Inherited from
|
|
339
|
+
|
|
340
|
+
`Transport._construct`
|
|
341
|
+
|
|
342
|
+
***
|
|
343
|
+
|
|
344
|
+
### \_destroy()
|
|
345
|
+
|
|
346
|
+
> **\_destroy**(`error`, `callback`): `void`
|
|
347
|
+
|
|
348
|
+
Defined in: node\_modules/@types/node/stream.d.ts:829
|
|
349
|
+
|
|
350
|
+
#### Parameters
|
|
351
|
+
|
|
352
|
+
##### error
|
|
353
|
+
|
|
354
|
+
`Error` \| `null`
|
|
355
|
+
|
|
356
|
+
##### callback
|
|
357
|
+
|
|
358
|
+
(`error?`) => `void`
|
|
359
|
+
|
|
360
|
+
#### Returns
|
|
361
|
+
|
|
362
|
+
`void`
|
|
363
|
+
|
|
364
|
+
#### Inherited from
|
|
365
|
+
|
|
366
|
+
`Transport._destroy`
|
|
367
|
+
|
|
368
|
+
***
|
|
369
|
+
|
|
370
|
+
### \_final()
|
|
371
|
+
|
|
372
|
+
> **\_final**(`callback`): `void`
|
|
373
|
+
|
|
374
|
+
Defined in: node\_modules/@types/node/stream.d.ts:830
|
|
375
|
+
|
|
376
|
+
#### Parameters
|
|
377
|
+
|
|
378
|
+
##### callback
|
|
379
|
+
|
|
380
|
+
(`error?`) => `void`
|
|
381
|
+
|
|
382
|
+
#### Returns
|
|
383
|
+
|
|
384
|
+
`void`
|
|
385
|
+
|
|
386
|
+
#### Inherited from
|
|
387
|
+
|
|
388
|
+
`Transport._final`
|
|
389
|
+
|
|
390
|
+
***
|
|
391
|
+
|
|
392
|
+
### \_write()
|
|
393
|
+
|
|
394
|
+
> **\_write**(`chunk`, `encoding`, `callback`): `void`
|
|
395
|
+
|
|
396
|
+
Defined in: node\_modules/@types/node/stream.d.ts:820
|
|
397
|
+
|
|
398
|
+
#### Parameters
|
|
399
|
+
|
|
400
|
+
##### chunk
|
|
401
|
+
|
|
402
|
+
`any`
|
|
403
|
+
|
|
404
|
+
##### encoding
|
|
405
|
+
|
|
406
|
+
`BufferEncoding`
|
|
407
|
+
|
|
408
|
+
##### callback
|
|
409
|
+
|
|
410
|
+
(`error?`) => `void`
|
|
411
|
+
|
|
412
|
+
#### Returns
|
|
413
|
+
|
|
414
|
+
`void`
|
|
415
|
+
|
|
416
|
+
#### Inherited from
|
|
417
|
+
|
|
418
|
+
`Transport._write`
|
|
419
|
+
|
|
420
|
+
***
|
|
421
|
+
|
|
422
|
+
### \_writev()?
|
|
423
|
+
|
|
424
|
+
> `optional` **\_writev**(`chunks`, `callback`): `void`
|
|
425
|
+
|
|
426
|
+
Defined in: node\_modules/@types/node/stream.d.ts:821
|
|
427
|
+
|
|
428
|
+
#### Parameters
|
|
429
|
+
|
|
430
|
+
##### chunks
|
|
431
|
+
|
|
432
|
+
`object`[]
|
|
433
|
+
|
|
434
|
+
##### callback
|
|
435
|
+
|
|
436
|
+
(`error?`) => `void`
|
|
437
|
+
|
|
438
|
+
#### Returns
|
|
439
|
+
|
|
440
|
+
`void`
|
|
441
|
+
|
|
442
|
+
#### Inherited from
|
|
443
|
+
|
|
444
|
+
`Transport._writev`
|
|
445
|
+
|
|
446
|
+
***
|
|
447
|
+
|
|
448
|
+
### \[asyncDispose\]()
|
|
449
|
+
|
|
450
|
+
> **\[asyncDispose\]**(): `Promise`\<`void`\>
|
|
451
|
+
|
|
452
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1014
|
|
453
|
+
|
|
454
|
+
Calls `writable.destroy()` with an `AbortError` and returns
|
|
455
|
+
a promise that fulfills when the stream is finished.
|
|
456
|
+
|
|
457
|
+
#### Returns
|
|
458
|
+
|
|
459
|
+
`Promise`\<`void`\>
|
|
460
|
+
|
|
461
|
+
#### Since
|
|
462
|
+
|
|
463
|
+
v22.4.0, v20.16.0
|
|
464
|
+
|
|
465
|
+
#### Inherited from
|
|
466
|
+
|
|
467
|
+
`Transport.[asyncDispose]`
|
|
468
|
+
|
|
469
|
+
***
|
|
470
|
+
|
|
471
|
+
### \[captureRejectionSymbol\]()?
|
|
472
|
+
|
|
473
|
+
> `optional` **\[captureRejectionSymbol\]**(`error`, `event`, ...`args`): `void`
|
|
474
|
+
|
|
475
|
+
Defined in: node\_modules/@types/node/events.d.ts:87
|
|
476
|
+
|
|
477
|
+
The `Symbol.for('nodejs.rejection')` method is called in case a
|
|
478
|
+
promise rejection happens when emitting an event and
|
|
479
|
+
`captureRejections` is enabled on the emitter.
|
|
480
|
+
It is possible to use `events.captureRejectionSymbol` in
|
|
481
|
+
place of `Symbol.for('nodejs.rejection')`.
|
|
482
|
+
|
|
483
|
+
```js
|
|
484
|
+
import { EventEmitter, captureRejectionSymbol } from 'node:events';
|
|
485
|
+
|
|
486
|
+
class MyClass extends EventEmitter {
|
|
487
|
+
constructor() {
|
|
488
|
+
super({ captureRejections: true });
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
[captureRejectionSymbol](err, event, ...args) {
|
|
492
|
+
console.log('rejection happened for', event, 'with', err, ...args);
|
|
493
|
+
this.destroy(err);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
destroy(err) {
|
|
497
|
+
// Tear the resource down here.
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
#### Parameters
|
|
503
|
+
|
|
504
|
+
##### error
|
|
505
|
+
|
|
506
|
+
`Error`
|
|
507
|
+
|
|
508
|
+
##### event
|
|
509
|
+
|
|
510
|
+
`string` \| `symbol`
|
|
511
|
+
|
|
512
|
+
##### args
|
|
513
|
+
|
|
514
|
+
...`any`[]
|
|
515
|
+
|
|
516
|
+
#### Returns
|
|
517
|
+
|
|
518
|
+
`void`
|
|
519
|
+
|
|
520
|
+
#### Since
|
|
521
|
+
|
|
522
|
+
v13.4.0, v12.16.0
|
|
523
|
+
|
|
524
|
+
#### Inherited from
|
|
525
|
+
|
|
526
|
+
`Transport.[captureRejectionSymbol]`
|
|
527
|
+
|
|
528
|
+
***
|
|
529
|
+
|
|
530
|
+
### addListener()
|
|
531
|
+
|
|
532
|
+
#### Call Signature
|
|
533
|
+
|
|
534
|
+
> **addListener**\<`E`\>(`eventName`, `listener`): `this`
|
|
535
|
+
|
|
536
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1016
|
|
537
|
+
|
|
538
|
+
Alias for `emitter.on(eventName, listener)`.
|
|
539
|
+
|
|
540
|
+
##### Type Parameters
|
|
541
|
+
|
|
542
|
+
###### E
|
|
543
|
+
|
|
544
|
+
`E` *extends* keyof `WritableEventMap`
|
|
545
|
+
|
|
546
|
+
##### Parameters
|
|
547
|
+
|
|
548
|
+
###### eventName
|
|
549
|
+
|
|
550
|
+
`E`
|
|
551
|
+
|
|
552
|
+
###### listener
|
|
553
|
+
|
|
554
|
+
(...`args`) => `void`
|
|
555
|
+
|
|
556
|
+
##### Returns
|
|
557
|
+
|
|
558
|
+
`this`
|
|
559
|
+
|
|
560
|
+
##### Since
|
|
561
|
+
|
|
562
|
+
v0.1.26
|
|
563
|
+
|
|
564
|
+
##### Inherited from
|
|
565
|
+
|
|
566
|
+
`Transport.addListener`
|
|
567
|
+
|
|
568
|
+
#### Call Signature
|
|
569
|
+
|
|
570
|
+
> **addListener**(`eventName`, `listener`): `this`
|
|
571
|
+
|
|
572
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1020
|
|
573
|
+
|
|
574
|
+
##### Parameters
|
|
575
|
+
|
|
576
|
+
###### eventName
|
|
577
|
+
|
|
578
|
+
`string` \| `symbol`
|
|
579
|
+
|
|
580
|
+
###### listener
|
|
581
|
+
|
|
582
|
+
(...`args`) => `void`
|
|
583
|
+
|
|
584
|
+
##### Returns
|
|
585
|
+
|
|
586
|
+
`this`
|
|
587
|
+
|
|
588
|
+
##### Inherited from
|
|
589
|
+
|
|
590
|
+
`Transport.addListener`
|
|
591
|
+
|
|
592
|
+
***
|
|
593
|
+
|
|
594
|
+
### close()
|
|
595
|
+
|
|
596
|
+
> **close**(): `void`
|
|
597
|
+
|
|
598
|
+
Defined in: [src/routes/AdminRoute.ts:27](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/routes/AdminRoute.ts#L27)
|
|
599
|
+
|
|
600
|
+
#### Returns
|
|
601
|
+
|
|
602
|
+
`void`
|
|
603
|
+
|
|
604
|
+
#### Overrides
|
|
605
|
+
|
|
606
|
+
`Transport.close`
|
|
607
|
+
|
|
608
|
+
***
|
|
609
|
+
|
|
610
|
+
### cork()
|
|
611
|
+
|
|
612
|
+
> **cork**(): `void`
|
|
613
|
+
|
|
614
|
+
Defined in: node\_modules/@types/node/stream.d.ts:957
|
|
615
|
+
|
|
616
|
+
The `writable.cork()` method forces all written data to be buffered in memory.
|
|
617
|
+
The buffered data will be flushed when either the [uncork](#uncork) or [end](#end) methods are called.
|
|
618
|
+
|
|
619
|
+
The primary intent of `writable.cork()` is to accommodate a situation in which
|
|
620
|
+
several small chunks are written to the stream in rapid succession. Instead of
|
|
621
|
+
immediately forwarding them to the underlying destination, `writable.cork()` buffers all the chunks until `writable.uncork()` is called, which will pass them
|
|
622
|
+
all to `writable._writev()`, if present. This prevents a head-of-line blocking
|
|
623
|
+
situation where data is being buffered while waiting for the first small chunk
|
|
624
|
+
to be processed. However, use of `writable.cork()` without implementing `writable._writev()` may have an adverse effect on throughput.
|
|
625
|
+
|
|
626
|
+
See also: `writable.uncork()`, `writable._writev()`.
|
|
627
|
+
|
|
628
|
+
#### Returns
|
|
629
|
+
|
|
630
|
+
`void`
|
|
631
|
+
|
|
632
|
+
#### Since
|
|
633
|
+
|
|
634
|
+
v0.11.2
|
|
635
|
+
|
|
636
|
+
#### Inherited from
|
|
637
|
+
|
|
638
|
+
`Transport.cork`
|
|
639
|
+
|
|
640
|
+
***
|
|
641
|
+
|
|
642
|
+
### destroy()
|
|
643
|
+
|
|
644
|
+
> **destroy**(`error?`): `this`
|
|
645
|
+
|
|
646
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1008
|
|
647
|
+
|
|
648
|
+
Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'` event (unless `emitClose` is set to `false`). After this call, the writable
|
|
649
|
+
stream has ended and subsequent calls to `write()` or `end()` will result in
|
|
650
|
+
an `ERR_STREAM_DESTROYED` error.
|
|
651
|
+
This is a destructive and immediate way to destroy a stream. Previous calls to `write()` may not have drained, and may trigger an `ERR_STREAM_DESTROYED` error.
|
|
652
|
+
Use `end()` instead of destroy if data should flush before close, or wait for
|
|
653
|
+
the `'drain'` event before destroying the stream.
|
|
654
|
+
|
|
655
|
+
Once `destroy()` has been called any further calls will be a no-op and no
|
|
656
|
+
further errors except from `_destroy()` may be emitted as `'error'`.
|
|
657
|
+
|
|
658
|
+
Implementors should not override this method,
|
|
659
|
+
but instead implement `writable._destroy()`.
|
|
660
|
+
|
|
661
|
+
#### Parameters
|
|
662
|
+
|
|
663
|
+
##### error?
|
|
664
|
+
|
|
665
|
+
`Error`
|
|
666
|
+
|
|
667
|
+
Optional, an error to emit with `'error'` event.
|
|
668
|
+
|
|
669
|
+
#### Returns
|
|
670
|
+
|
|
671
|
+
`this`
|
|
672
|
+
|
|
673
|
+
#### Since
|
|
674
|
+
|
|
675
|
+
v8.0.0
|
|
676
|
+
|
|
677
|
+
#### Inherited from
|
|
678
|
+
|
|
679
|
+
`Transport.destroy`
|
|
680
|
+
|
|
681
|
+
***
|
|
682
|
+
|
|
683
|
+
### emit()
|
|
684
|
+
|
|
685
|
+
#### Call Signature
|
|
686
|
+
|
|
687
|
+
> **emit**\<`E`\>(`eventName`, ...`args`): `boolean`
|
|
688
|
+
|
|
689
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1021
|
|
690
|
+
|
|
691
|
+
Synchronously calls each of the listeners registered for the event named
|
|
692
|
+
`eventName`, in the order they were registered, passing the supplied arguments
|
|
693
|
+
to each.
|
|
694
|
+
|
|
695
|
+
Returns `true` if the event had listeners, `false` otherwise.
|
|
696
|
+
|
|
697
|
+
```js
|
|
698
|
+
import { EventEmitter } from 'node:events';
|
|
699
|
+
const myEmitter = new EventEmitter();
|
|
700
|
+
|
|
701
|
+
// First listener
|
|
702
|
+
myEmitter.on('event', function firstListener() {
|
|
703
|
+
console.log('Helloooo! first listener');
|
|
704
|
+
});
|
|
705
|
+
// Second listener
|
|
706
|
+
myEmitter.on('event', function secondListener(arg1, arg2) {
|
|
707
|
+
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
|
|
708
|
+
});
|
|
709
|
+
// Third listener
|
|
710
|
+
myEmitter.on('event', function thirdListener(...args) {
|
|
711
|
+
const parameters = args.join(', ');
|
|
712
|
+
console.log(`event with parameters ${parameters} in third listener`);
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
console.log(myEmitter.listeners('event'));
|
|
716
|
+
|
|
717
|
+
myEmitter.emit('event', 1, 2, 3, 4, 5);
|
|
718
|
+
|
|
719
|
+
// Prints:
|
|
720
|
+
// [
|
|
721
|
+
// [Function: firstListener],
|
|
722
|
+
// [Function: secondListener],
|
|
723
|
+
// [Function: thirdListener]
|
|
724
|
+
// ]
|
|
725
|
+
// Helloooo! first listener
|
|
726
|
+
// event with parameters 1, 2 in second listener
|
|
727
|
+
// event with parameters 1, 2, 3, 4, 5 in third listener
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
##### Type Parameters
|
|
731
|
+
|
|
732
|
+
###### E
|
|
733
|
+
|
|
734
|
+
`E` *extends* keyof `WritableEventMap`
|
|
735
|
+
|
|
736
|
+
##### Parameters
|
|
737
|
+
|
|
738
|
+
###### eventName
|
|
739
|
+
|
|
740
|
+
`E`
|
|
741
|
+
|
|
742
|
+
###### args
|
|
743
|
+
|
|
744
|
+
...`WritableEventMap`\[`E`\]
|
|
745
|
+
|
|
746
|
+
##### Returns
|
|
747
|
+
|
|
748
|
+
`boolean`
|
|
749
|
+
|
|
750
|
+
##### Since
|
|
751
|
+
|
|
752
|
+
v0.1.26
|
|
753
|
+
|
|
754
|
+
##### Inherited from
|
|
755
|
+
|
|
756
|
+
`Transport.emit`
|
|
757
|
+
|
|
758
|
+
#### Call Signature
|
|
759
|
+
|
|
760
|
+
> **emit**(`eventName`, ...`args`): `boolean`
|
|
761
|
+
|
|
762
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1022
|
|
763
|
+
|
|
764
|
+
##### Parameters
|
|
765
|
+
|
|
766
|
+
###### eventName
|
|
767
|
+
|
|
768
|
+
`string` \| `symbol`
|
|
769
|
+
|
|
770
|
+
###### args
|
|
771
|
+
|
|
772
|
+
...`any`[]
|
|
773
|
+
|
|
774
|
+
##### Returns
|
|
775
|
+
|
|
776
|
+
`boolean`
|
|
777
|
+
|
|
778
|
+
##### Inherited from
|
|
779
|
+
|
|
780
|
+
`Transport.emit`
|
|
781
|
+
|
|
782
|
+
***
|
|
783
|
+
|
|
784
|
+
### end()
|
|
785
|
+
|
|
786
|
+
#### Call Signature
|
|
787
|
+
|
|
788
|
+
> **end**(`cb?`): `this`
|
|
789
|
+
|
|
790
|
+
Defined in: node\_modules/@types/node/stream.d.ts:923
|
|
791
|
+
|
|
792
|
+
Calling the `writable.end()` method signals that no more data will be written
|
|
793
|
+
to the `Writable`. The optional `chunk` and `encoding` arguments allow one
|
|
794
|
+
final additional chunk of data to be written immediately before closing the
|
|
795
|
+
stream.
|
|
796
|
+
|
|
797
|
+
Calling the [write](#write) method after calling [end](#end) will raise an error.
|
|
798
|
+
|
|
799
|
+
```js
|
|
800
|
+
// Write 'hello, ' and then end with 'world!'.
|
|
801
|
+
import fs from 'node:fs';
|
|
802
|
+
const file = fs.createWriteStream('example.txt');
|
|
803
|
+
file.write('hello, ');
|
|
804
|
+
file.end('world!');
|
|
805
|
+
// Writing more now is not allowed!
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
##### Parameters
|
|
809
|
+
|
|
810
|
+
###### cb?
|
|
811
|
+
|
|
812
|
+
() => `void`
|
|
813
|
+
|
|
814
|
+
Callback for when the stream is finished.
|
|
815
|
+
|
|
816
|
+
##### Returns
|
|
817
|
+
|
|
818
|
+
`this`
|
|
819
|
+
|
|
820
|
+
##### Since
|
|
821
|
+
|
|
822
|
+
v0.9.4
|
|
823
|
+
|
|
824
|
+
##### Inherited from
|
|
825
|
+
|
|
826
|
+
`Transport.end`
|
|
827
|
+
|
|
828
|
+
#### Call Signature
|
|
829
|
+
|
|
830
|
+
> **end**(`chunk`, `cb?`): `this`
|
|
831
|
+
|
|
832
|
+
Defined in: node\_modules/@types/node/stream.d.ts:932
|
|
833
|
+
|
|
834
|
+
Signals that no more data will be written, with one final chunk of data.
|
|
835
|
+
|
|
836
|
+
##### Parameters
|
|
837
|
+
|
|
838
|
+
###### chunk
|
|
839
|
+
|
|
840
|
+
`any`
|
|
841
|
+
|
|
842
|
+
Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
|
|
843
|
+
{TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
|
|
844
|
+
|
|
845
|
+
###### cb?
|
|
846
|
+
|
|
847
|
+
() => `void`
|
|
848
|
+
|
|
849
|
+
Callback for when the stream is finished.
|
|
850
|
+
|
|
851
|
+
##### Returns
|
|
852
|
+
|
|
853
|
+
`this`
|
|
854
|
+
|
|
855
|
+
##### See
|
|
856
|
+
|
|
857
|
+
Writable.end for full details.
|
|
858
|
+
|
|
859
|
+
##### Since
|
|
860
|
+
|
|
861
|
+
v0.9.4
|
|
862
|
+
|
|
863
|
+
##### Inherited from
|
|
864
|
+
|
|
865
|
+
`Transport.end`
|
|
866
|
+
|
|
867
|
+
#### Call Signature
|
|
868
|
+
|
|
869
|
+
> **end**(`chunk`, `encoding`, `cb?`): `this`
|
|
870
|
+
|
|
871
|
+
Defined in: node\_modules/@types/node/stream.d.ts:942
|
|
872
|
+
|
|
873
|
+
Signals that no more data will be written, with one final chunk of data.
|
|
874
|
+
|
|
875
|
+
##### Parameters
|
|
876
|
+
|
|
877
|
+
###### chunk
|
|
878
|
+
|
|
879
|
+
`any`
|
|
880
|
+
|
|
881
|
+
Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
|
|
882
|
+
{TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
|
|
883
|
+
|
|
884
|
+
###### encoding
|
|
885
|
+
|
|
886
|
+
`BufferEncoding`
|
|
887
|
+
|
|
888
|
+
The encoding if `chunk` is a string
|
|
889
|
+
|
|
890
|
+
###### cb?
|
|
891
|
+
|
|
892
|
+
() => `void`
|
|
893
|
+
|
|
894
|
+
Callback for when the stream is finished.
|
|
895
|
+
|
|
896
|
+
##### Returns
|
|
897
|
+
|
|
898
|
+
`this`
|
|
899
|
+
|
|
900
|
+
##### See
|
|
901
|
+
|
|
902
|
+
Writable.end for full details.
|
|
903
|
+
|
|
904
|
+
##### Since
|
|
905
|
+
|
|
906
|
+
v0.9.4
|
|
907
|
+
|
|
908
|
+
##### Inherited from
|
|
909
|
+
|
|
910
|
+
`Transport.end`
|
|
911
|
+
|
|
912
|
+
***
|
|
913
|
+
|
|
914
|
+
### eventNames()
|
|
915
|
+
|
|
916
|
+
> **eventNames**(): (`string` \| `symbol`)[]
|
|
917
|
+
|
|
918
|
+
Defined in: node\_modules/@types/node/events.d.ts:154
|
|
919
|
+
|
|
920
|
+
Returns an array listing the events for which the emitter has registered
|
|
921
|
+
listeners.
|
|
922
|
+
|
|
923
|
+
```js
|
|
924
|
+
import { EventEmitter } from 'node:events';
|
|
925
|
+
|
|
926
|
+
const myEE = new EventEmitter();
|
|
927
|
+
myEE.on('foo', () => {});
|
|
928
|
+
myEE.on('bar', () => {});
|
|
929
|
+
|
|
930
|
+
const sym = Symbol('symbol');
|
|
931
|
+
myEE.on(sym, () => {});
|
|
932
|
+
|
|
933
|
+
console.log(myEE.eventNames());
|
|
934
|
+
// Prints: [ 'foo', 'bar', Symbol(symbol) ]
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
#### Returns
|
|
938
|
+
|
|
939
|
+
(`string` \| `symbol`)[]
|
|
940
|
+
|
|
941
|
+
#### Since
|
|
942
|
+
|
|
943
|
+
v6.0.0
|
|
944
|
+
|
|
945
|
+
#### Inherited from
|
|
946
|
+
|
|
947
|
+
`Transport.eventNames`
|
|
948
|
+
|
|
949
|
+
***
|
|
950
|
+
|
|
951
|
+
### getMaxListeners()
|
|
952
|
+
|
|
953
|
+
> **getMaxListeners**(): `number`
|
|
954
|
+
|
|
955
|
+
Defined in: node\_modules/@types/node/events.d.ts:161
|
|
956
|
+
|
|
957
|
+
Returns the current max listener value for the `EventEmitter` which is either
|
|
958
|
+
set by `emitter.setMaxListeners(n)` or defaults to
|
|
959
|
+
`events.defaultMaxListeners`.
|
|
960
|
+
|
|
961
|
+
#### Returns
|
|
962
|
+
|
|
963
|
+
`number`
|
|
964
|
+
|
|
965
|
+
#### Since
|
|
966
|
+
|
|
967
|
+
v1.0.0
|
|
968
|
+
|
|
969
|
+
#### Inherited from
|
|
970
|
+
|
|
971
|
+
`Transport.getMaxListeners`
|
|
972
|
+
|
|
973
|
+
***
|
|
974
|
+
|
|
975
|
+
### listenerCount()
|
|
976
|
+
|
|
977
|
+
#### Call Signature
|
|
978
|
+
|
|
979
|
+
> **listenerCount**\<`E`\>(`eventName`, `listener?`): `number`
|
|
980
|
+
|
|
981
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1023
|
|
982
|
+
|
|
983
|
+
Returns the number of listeners listening for the event named `eventName`.
|
|
984
|
+
If `listener` is provided, it will return how many times the listener is found
|
|
985
|
+
in the list of the listeners of the event.
|
|
986
|
+
|
|
987
|
+
##### Type Parameters
|
|
988
|
+
|
|
989
|
+
###### E
|
|
990
|
+
|
|
991
|
+
`E` *extends* keyof `WritableEventMap`
|
|
992
|
+
|
|
993
|
+
##### Parameters
|
|
994
|
+
|
|
995
|
+
###### eventName
|
|
996
|
+
|
|
997
|
+
`E`
|
|
998
|
+
|
|
999
|
+
The name of the event being listened for
|
|
1000
|
+
|
|
1001
|
+
###### listener?
|
|
1002
|
+
|
|
1003
|
+
(...`args`) => `void`
|
|
1004
|
+
|
|
1005
|
+
The event handler function
|
|
1006
|
+
|
|
1007
|
+
##### Returns
|
|
1008
|
+
|
|
1009
|
+
`number`
|
|
1010
|
+
|
|
1011
|
+
##### Since
|
|
1012
|
+
|
|
1013
|
+
v3.2.0
|
|
1014
|
+
|
|
1015
|
+
##### Inherited from
|
|
1016
|
+
|
|
1017
|
+
`Transport.listenerCount`
|
|
1018
|
+
|
|
1019
|
+
#### Call Signature
|
|
1020
|
+
|
|
1021
|
+
> **listenerCount**(`eventName`, `listener?`): `number`
|
|
1022
|
+
|
|
1023
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1027
|
|
1024
|
+
|
|
1025
|
+
##### Parameters
|
|
1026
|
+
|
|
1027
|
+
###### eventName
|
|
1028
|
+
|
|
1029
|
+
`string` \| `symbol`
|
|
1030
|
+
|
|
1031
|
+
###### listener?
|
|
1032
|
+
|
|
1033
|
+
(...`args`) => `void`
|
|
1034
|
+
|
|
1035
|
+
##### Returns
|
|
1036
|
+
|
|
1037
|
+
`number`
|
|
1038
|
+
|
|
1039
|
+
##### Inherited from
|
|
1040
|
+
|
|
1041
|
+
`Transport.listenerCount`
|
|
1042
|
+
|
|
1043
|
+
***
|
|
1044
|
+
|
|
1045
|
+
### listeners()
|
|
1046
|
+
|
|
1047
|
+
#### Call Signature
|
|
1048
|
+
|
|
1049
|
+
> **listeners**\<`E`\>(`eventName`): (...`args`) => `void`[]
|
|
1050
|
+
|
|
1051
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1028
|
|
1052
|
+
|
|
1053
|
+
Returns a copy of the array of listeners for the event named `eventName`.
|
|
1054
|
+
|
|
1055
|
+
```js
|
|
1056
|
+
server.on('connection', (stream) => {
|
|
1057
|
+
console.log('someone connected!');
|
|
1058
|
+
});
|
|
1059
|
+
console.log(util.inspect(server.listeners('connection')));
|
|
1060
|
+
// Prints: [ [Function] ]
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
##### Type Parameters
|
|
1064
|
+
|
|
1065
|
+
###### E
|
|
1066
|
+
|
|
1067
|
+
`E` *extends* keyof `WritableEventMap`
|
|
1068
|
+
|
|
1069
|
+
##### Parameters
|
|
1070
|
+
|
|
1071
|
+
###### eventName
|
|
1072
|
+
|
|
1073
|
+
`E`
|
|
1074
|
+
|
|
1075
|
+
##### Returns
|
|
1076
|
+
|
|
1077
|
+
(...`args`) => `void`[]
|
|
1078
|
+
|
|
1079
|
+
##### Since
|
|
1080
|
+
|
|
1081
|
+
v0.1.26
|
|
1082
|
+
|
|
1083
|
+
##### Inherited from
|
|
1084
|
+
|
|
1085
|
+
`Transport.listeners`
|
|
1086
|
+
|
|
1087
|
+
#### Call Signature
|
|
1088
|
+
|
|
1089
|
+
> **listeners**(`eventName`): (...`args`) => `void`[]
|
|
1090
|
+
|
|
1091
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1029
|
|
1092
|
+
|
|
1093
|
+
##### Parameters
|
|
1094
|
+
|
|
1095
|
+
###### eventName
|
|
1096
|
+
|
|
1097
|
+
`string` \| `symbol`
|
|
1098
|
+
|
|
1099
|
+
##### Returns
|
|
1100
|
+
|
|
1101
|
+
(...`args`) => `void`[]
|
|
1102
|
+
|
|
1103
|
+
##### Inherited from
|
|
1104
|
+
|
|
1105
|
+
`Transport.listeners`
|
|
1106
|
+
|
|
1107
|
+
***
|
|
1108
|
+
|
|
1109
|
+
### log()
|
|
1110
|
+
|
|
1111
|
+
> **log**(`info`, `next`): `any`
|
|
1112
|
+
|
|
1113
|
+
Defined in: [src/routes/AdminRoute.ts:31](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/routes/AdminRoute.ts#L31)
|
|
1114
|
+
|
|
1115
|
+
#### Parameters
|
|
1116
|
+
|
|
1117
|
+
##### info
|
|
1118
|
+
|
|
1119
|
+
`any`
|
|
1120
|
+
|
|
1121
|
+
##### next
|
|
1122
|
+
|
|
1123
|
+
`Function`
|
|
1124
|
+
|
|
1125
|
+
#### Returns
|
|
1126
|
+
|
|
1127
|
+
`any`
|
|
1128
|
+
|
|
1129
|
+
#### Overrides
|
|
1130
|
+
|
|
1131
|
+
`Transport.log`
|
|
1132
|
+
|
|
1133
|
+
***
|
|
1134
|
+
|
|
1135
|
+
### logv()?
|
|
1136
|
+
|
|
1137
|
+
> `optional` **logv**(`info`, `next`): `any`
|
|
1138
|
+
|
|
1139
|
+
Defined in: node\_modules/winston-transport/index.d.ts:21
|
|
1140
|
+
|
|
1141
|
+
#### Parameters
|
|
1142
|
+
|
|
1143
|
+
##### info
|
|
1144
|
+
|
|
1145
|
+
`any`
|
|
1146
|
+
|
|
1147
|
+
##### next
|
|
1148
|
+
|
|
1149
|
+
() => `void`
|
|
1150
|
+
|
|
1151
|
+
#### Returns
|
|
1152
|
+
|
|
1153
|
+
`any`
|
|
1154
|
+
|
|
1155
|
+
#### Inherited from
|
|
1156
|
+
|
|
1157
|
+
`Transport.logv`
|
|
1158
|
+
|
|
1159
|
+
***
|
|
1160
|
+
|
|
1161
|
+
### off()
|
|
1162
|
+
|
|
1163
|
+
#### Call Signature
|
|
1164
|
+
|
|
1165
|
+
> **off**\<`E`\>(`eventName`, `listener`): `this`
|
|
1166
|
+
|
|
1167
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1030
|
|
1168
|
+
|
|
1169
|
+
Alias for `emitter.removeListener()`.
|
|
1170
|
+
|
|
1171
|
+
##### Type Parameters
|
|
1172
|
+
|
|
1173
|
+
###### E
|
|
1174
|
+
|
|
1175
|
+
`E` *extends* keyof `WritableEventMap`
|
|
1176
|
+
|
|
1177
|
+
##### Parameters
|
|
1178
|
+
|
|
1179
|
+
###### eventName
|
|
1180
|
+
|
|
1181
|
+
`E`
|
|
1182
|
+
|
|
1183
|
+
###### listener
|
|
1184
|
+
|
|
1185
|
+
(...`args`) => `void`
|
|
1186
|
+
|
|
1187
|
+
##### Returns
|
|
1188
|
+
|
|
1189
|
+
`this`
|
|
1190
|
+
|
|
1191
|
+
##### Since
|
|
1192
|
+
|
|
1193
|
+
v10.0.0
|
|
1194
|
+
|
|
1195
|
+
##### Inherited from
|
|
1196
|
+
|
|
1197
|
+
`Transport.off`
|
|
1198
|
+
|
|
1199
|
+
#### Call Signature
|
|
1200
|
+
|
|
1201
|
+
> **off**(`eventName`, `listener`): `this`
|
|
1202
|
+
|
|
1203
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1031
|
|
1204
|
+
|
|
1205
|
+
##### Parameters
|
|
1206
|
+
|
|
1207
|
+
###### eventName
|
|
1208
|
+
|
|
1209
|
+
`string` \| `symbol`
|
|
1210
|
+
|
|
1211
|
+
###### listener
|
|
1212
|
+
|
|
1213
|
+
(...`args`) => `void`
|
|
1214
|
+
|
|
1215
|
+
##### Returns
|
|
1216
|
+
|
|
1217
|
+
`this`
|
|
1218
|
+
|
|
1219
|
+
##### Inherited from
|
|
1220
|
+
|
|
1221
|
+
`Transport.off`
|
|
1222
|
+
|
|
1223
|
+
***
|
|
1224
|
+
|
|
1225
|
+
### on()
|
|
1226
|
+
|
|
1227
|
+
#### Call Signature
|
|
1228
|
+
|
|
1229
|
+
> **on**\<`E`\>(`eventName`, `listener`): `this`
|
|
1230
|
+
|
|
1231
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1032
|
|
1232
|
+
|
|
1233
|
+
Adds the `listener` function to the end of the listeners array for the
|
|
1234
|
+
event named `eventName`. No checks are made to see if the `listener` has
|
|
1235
|
+
already been added. Multiple calls passing the same combination of `eventName`
|
|
1236
|
+
and `listener` will result in the `listener` being added, and called, multiple
|
|
1237
|
+
times.
|
|
1238
|
+
|
|
1239
|
+
```js
|
|
1240
|
+
server.on('connection', (stream) => {
|
|
1241
|
+
console.log('someone connected!');
|
|
1242
|
+
});
|
|
1243
|
+
```
|
|
1244
|
+
|
|
1245
|
+
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
1246
|
+
|
|
1247
|
+
By default, event listeners are invoked in the order they are added. The
|
|
1248
|
+
`emitter.prependListener()` method can be used as an alternative to add the
|
|
1249
|
+
event listener to the beginning of the listeners array.
|
|
1250
|
+
|
|
1251
|
+
```js
|
|
1252
|
+
import { EventEmitter } from 'node:events';
|
|
1253
|
+
const myEE = new EventEmitter();
|
|
1254
|
+
myEE.on('foo', () => console.log('a'));
|
|
1255
|
+
myEE.prependListener('foo', () => console.log('b'));
|
|
1256
|
+
myEE.emit('foo');
|
|
1257
|
+
// Prints:
|
|
1258
|
+
// b
|
|
1259
|
+
// a
|
|
1260
|
+
```
|
|
1261
|
+
|
|
1262
|
+
##### Type Parameters
|
|
1263
|
+
|
|
1264
|
+
###### E
|
|
1265
|
+
|
|
1266
|
+
`E` *extends* keyof `WritableEventMap`
|
|
1267
|
+
|
|
1268
|
+
##### Parameters
|
|
1269
|
+
|
|
1270
|
+
###### eventName
|
|
1271
|
+
|
|
1272
|
+
`E`
|
|
1273
|
+
|
|
1274
|
+
The name of the event.
|
|
1275
|
+
|
|
1276
|
+
###### listener
|
|
1277
|
+
|
|
1278
|
+
(...`args`) => `void`
|
|
1279
|
+
|
|
1280
|
+
The callback function
|
|
1281
|
+
|
|
1282
|
+
##### Returns
|
|
1283
|
+
|
|
1284
|
+
`this`
|
|
1285
|
+
|
|
1286
|
+
##### Since
|
|
1287
|
+
|
|
1288
|
+
v0.1.101
|
|
1289
|
+
|
|
1290
|
+
##### Inherited from
|
|
1291
|
+
|
|
1292
|
+
`Transport.on`
|
|
1293
|
+
|
|
1294
|
+
#### Call Signature
|
|
1295
|
+
|
|
1296
|
+
> **on**(`eventName`, `listener`): `this`
|
|
1297
|
+
|
|
1298
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1033
|
|
1299
|
+
|
|
1300
|
+
##### Parameters
|
|
1301
|
+
|
|
1302
|
+
###### eventName
|
|
1303
|
+
|
|
1304
|
+
`string` \| `symbol`
|
|
1305
|
+
|
|
1306
|
+
###### listener
|
|
1307
|
+
|
|
1308
|
+
(...`args`) => `void`
|
|
1309
|
+
|
|
1310
|
+
##### Returns
|
|
1311
|
+
|
|
1312
|
+
`this`
|
|
1313
|
+
|
|
1314
|
+
##### Inherited from
|
|
1315
|
+
|
|
1316
|
+
`Transport.on`
|
|
1317
|
+
|
|
1318
|
+
***
|
|
1319
|
+
|
|
1320
|
+
### once()
|
|
1321
|
+
|
|
1322
|
+
#### Call Signature
|
|
1323
|
+
|
|
1324
|
+
> **once**\<`E`\>(`eventName`, `listener`): `this`
|
|
1325
|
+
|
|
1326
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1034
|
|
1327
|
+
|
|
1328
|
+
Adds a **one-time** `listener` function for the event named `eventName`. The
|
|
1329
|
+
next time `eventName` is triggered, this listener is removed and then invoked.
|
|
1330
|
+
|
|
1331
|
+
```js
|
|
1332
|
+
server.once('connection', (stream) => {
|
|
1333
|
+
console.log('Ah, we have our first user!');
|
|
1334
|
+
});
|
|
1335
|
+
```
|
|
1336
|
+
|
|
1337
|
+
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
1338
|
+
|
|
1339
|
+
By default, event listeners are invoked in the order they are added. The
|
|
1340
|
+
`emitter.prependOnceListener()` method can be used as an alternative to add the
|
|
1341
|
+
event listener to the beginning of the listeners array.
|
|
1342
|
+
|
|
1343
|
+
```js
|
|
1344
|
+
import { EventEmitter } from 'node:events';
|
|
1345
|
+
const myEE = new EventEmitter();
|
|
1346
|
+
myEE.once('foo', () => console.log('a'));
|
|
1347
|
+
myEE.prependOnceListener('foo', () => console.log('b'));
|
|
1348
|
+
myEE.emit('foo');
|
|
1349
|
+
// Prints:
|
|
1350
|
+
// b
|
|
1351
|
+
// a
|
|
1352
|
+
```
|
|
1353
|
+
|
|
1354
|
+
##### Type Parameters
|
|
1355
|
+
|
|
1356
|
+
###### E
|
|
1357
|
+
|
|
1358
|
+
`E` *extends* keyof `WritableEventMap`
|
|
1359
|
+
|
|
1360
|
+
##### Parameters
|
|
1361
|
+
|
|
1362
|
+
###### eventName
|
|
1363
|
+
|
|
1364
|
+
`E`
|
|
1365
|
+
|
|
1366
|
+
The name of the event.
|
|
1367
|
+
|
|
1368
|
+
###### listener
|
|
1369
|
+
|
|
1370
|
+
(...`args`) => `void`
|
|
1371
|
+
|
|
1372
|
+
The callback function
|
|
1373
|
+
|
|
1374
|
+
##### Returns
|
|
1375
|
+
|
|
1376
|
+
`this`
|
|
1377
|
+
|
|
1378
|
+
##### Since
|
|
1379
|
+
|
|
1380
|
+
v0.3.0
|
|
1381
|
+
|
|
1382
|
+
##### Inherited from
|
|
1383
|
+
|
|
1384
|
+
`Transport.once`
|
|
1385
|
+
|
|
1386
|
+
#### Call Signature
|
|
1387
|
+
|
|
1388
|
+
> **once**(`eventName`, `listener`): `this`
|
|
1389
|
+
|
|
1390
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1038
|
|
1391
|
+
|
|
1392
|
+
##### Parameters
|
|
1393
|
+
|
|
1394
|
+
###### eventName
|
|
1395
|
+
|
|
1396
|
+
`string` \| `symbol`
|
|
1397
|
+
|
|
1398
|
+
###### listener
|
|
1399
|
+
|
|
1400
|
+
(...`args`) => `void`
|
|
1401
|
+
|
|
1402
|
+
##### Returns
|
|
1403
|
+
|
|
1404
|
+
`this`
|
|
1405
|
+
|
|
1406
|
+
##### Inherited from
|
|
1407
|
+
|
|
1408
|
+
`Transport.once`
|
|
1409
|
+
|
|
1410
|
+
***
|
|
1411
|
+
|
|
1412
|
+
### pipe()
|
|
1413
|
+
|
|
1414
|
+
> **pipe**\<`T`\>(`destination`, `options?`): `T`
|
|
1415
|
+
|
|
1416
|
+
Defined in: node\_modules/@types/node/stream.d.ts:10
|
|
1417
|
+
|
|
1418
|
+
#### Type Parameters
|
|
1419
|
+
|
|
1420
|
+
##### T
|
|
1421
|
+
|
|
1422
|
+
`T` *extends* `WritableStream`
|
|
1423
|
+
|
|
1424
|
+
#### Parameters
|
|
1425
|
+
|
|
1426
|
+
##### destination
|
|
1427
|
+
|
|
1428
|
+
`T`
|
|
1429
|
+
|
|
1430
|
+
##### options?
|
|
1431
|
+
|
|
1432
|
+
`PipeOptions`
|
|
1433
|
+
|
|
1434
|
+
#### Returns
|
|
1435
|
+
|
|
1436
|
+
`T`
|
|
1437
|
+
|
|
1438
|
+
#### Since
|
|
1439
|
+
|
|
1440
|
+
v0.9.4
|
|
1441
|
+
|
|
1442
|
+
#### Inherited from
|
|
1443
|
+
|
|
1444
|
+
`Transport.pipe`
|
|
1445
|
+
|
|
1446
|
+
***
|
|
1447
|
+
|
|
1448
|
+
### prependListener()
|
|
1449
|
+
|
|
1450
|
+
#### Call Signature
|
|
1451
|
+
|
|
1452
|
+
> **prependListener**\<`E`\>(`eventName`, `listener`): `this`
|
|
1453
|
+
|
|
1454
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1039
|
|
1455
|
+
|
|
1456
|
+
Adds the `listener` function to the _beginning_ of the listeners array for the
|
|
1457
|
+
event named `eventName`. No checks are made to see if the `listener` has
|
|
1458
|
+
already been added. Multiple calls passing the same combination of `eventName`
|
|
1459
|
+
and `listener` will result in the `listener` being added, and called, multiple
|
|
1460
|
+
times.
|
|
1461
|
+
|
|
1462
|
+
```js
|
|
1463
|
+
server.prependListener('connection', (stream) => {
|
|
1464
|
+
console.log('someone connected!');
|
|
1465
|
+
});
|
|
1466
|
+
```
|
|
1467
|
+
|
|
1468
|
+
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
1469
|
+
|
|
1470
|
+
##### Type Parameters
|
|
1471
|
+
|
|
1472
|
+
###### E
|
|
1473
|
+
|
|
1474
|
+
`E` *extends* keyof `WritableEventMap`
|
|
1475
|
+
|
|
1476
|
+
##### Parameters
|
|
1477
|
+
|
|
1478
|
+
###### eventName
|
|
1479
|
+
|
|
1480
|
+
`E`
|
|
1481
|
+
|
|
1482
|
+
The name of the event.
|
|
1483
|
+
|
|
1484
|
+
###### listener
|
|
1485
|
+
|
|
1486
|
+
(...`args`) => `void`
|
|
1487
|
+
|
|
1488
|
+
The callback function
|
|
1489
|
+
|
|
1490
|
+
##### Returns
|
|
1491
|
+
|
|
1492
|
+
`this`
|
|
1493
|
+
|
|
1494
|
+
##### Since
|
|
1495
|
+
|
|
1496
|
+
v6.0.0
|
|
1497
|
+
|
|
1498
|
+
##### Inherited from
|
|
1499
|
+
|
|
1500
|
+
`Transport.prependListener`
|
|
1501
|
+
|
|
1502
|
+
#### Call Signature
|
|
1503
|
+
|
|
1504
|
+
> **prependListener**(`eventName`, `listener`): `this`
|
|
1505
|
+
|
|
1506
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1043
|
|
1507
|
+
|
|
1508
|
+
##### Parameters
|
|
1509
|
+
|
|
1510
|
+
###### eventName
|
|
1511
|
+
|
|
1512
|
+
`string` \| `symbol`
|
|
1513
|
+
|
|
1514
|
+
###### listener
|
|
1515
|
+
|
|
1516
|
+
(...`args`) => `void`
|
|
1517
|
+
|
|
1518
|
+
##### Returns
|
|
1519
|
+
|
|
1520
|
+
`this`
|
|
1521
|
+
|
|
1522
|
+
##### Inherited from
|
|
1523
|
+
|
|
1524
|
+
`Transport.prependListener`
|
|
1525
|
+
|
|
1526
|
+
***
|
|
1527
|
+
|
|
1528
|
+
### prependOnceListener()
|
|
1529
|
+
|
|
1530
|
+
#### Call Signature
|
|
1531
|
+
|
|
1532
|
+
> **prependOnceListener**\<`E`\>(`eventName`, `listener`): `this`
|
|
1533
|
+
|
|
1534
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1044
|
|
1535
|
+
|
|
1536
|
+
Adds a **one-time** `listener` function for the event named `eventName` to the
|
|
1537
|
+
_beginning_ of the listeners array. The next time `eventName` is triggered, this
|
|
1538
|
+
listener is removed, and then invoked.
|
|
1539
|
+
|
|
1540
|
+
```js
|
|
1541
|
+
server.prependOnceListener('connection', (stream) => {
|
|
1542
|
+
console.log('Ah, we have our first user!');
|
|
1543
|
+
});
|
|
1544
|
+
```
|
|
1545
|
+
|
|
1546
|
+
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
1547
|
+
|
|
1548
|
+
##### Type Parameters
|
|
1549
|
+
|
|
1550
|
+
###### E
|
|
1551
|
+
|
|
1552
|
+
`E` *extends* keyof `WritableEventMap`
|
|
1553
|
+
|
|
1554
|
+
##### Parameters
|
|
1555
|
+
|
|
1556
|
+
###### eventName
|
|
1557
|
+
|
|
1558
|
+
`E`
|
|
1559
|
+
|
|
1560
|
+
The name of the event.
|
|
1561
|
+
|
|
1562
|
+
###### listener
|
|
1563
|
+
|
|
1564
|
+
(...`args`) => `void`
|
|
1565
|
+
|
|
1566
|
+
The callback function
|
|
1567
|
+
|
|
1568
|
+
##### Returns
|
|
1569
|
+
|
|
1570
|
+
`this`
|
|
1571
|
+
|
|
1572
|
+
##### Since
|
|
1573
|
+
|
|
1574
|
+
v6.0.0
|
|
1575
|
+
|
|
1576
|
+
##### Inherited from
|
|
1577
|
+
|
|
1578
|
+
`Transport.prependOnceListener`
|
|
1579
|
+
|
|
1580
|
+
#### Call Signature
|
|
1581
|
+
|
|
1582
|
+
> **prependOnceListener**(`eventName`, `listener`): `this`
|
|
1583
|
+
|
|
1584
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1048
|
|
1585
|
+
|
|
1586
|
+
##### Parameters
|
|
1587
|
+
|
|
1588
|
+
###### eventName
|
|
1589
|
+
|
|
1590
|
+
`string` \| `symbol`
|
|
1591
|
+
|
|
1592
|
+
###### listener
|
|
1593
|
+
|
|
1594
|
+
(...`args`) => `void`
|
|
1595
|
+
|
|
1596
|
+
##### Returns
|
|
1597
|
+
|
|
1598
|
+
`this`
|
|
1599
|
+
|
|
1600
|
+
##### Inherited from
|
|
1601
|
+
|
|
1602
|
+
`Transport.prependOnceListener`
|
|
1603
|
+
|
|
1604
|
+
***
|
|
1605
|
+
|
|
1606
|
+
### rawListeners()
|
|
1607
|
+
|
|
1608
|
+
#### Call Signature
|
|
1609
|
+
|
|
1610
|
+
> **rawListeners**\<`E`\>(`eventName`): (...`args`) => `void`[]
|
|
1611
|
+
|
|
1612
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1049
|
|
1613
|
+
|
|
1614
|
+
Returns a copy of the array of listeners for the event named `eventName`,
|
|
1615
|
+
including any wrappers (such as those created by `.once()`).
|
|
1616
|
+
|
|
1617
|
+
```js
|
|
1618
|
+
import { EventEmitter } from 'node:events';
|
|
1619
|
+
const emitter = new EventEmitter();
|
|
1620
|
+
emitter.once('log', () => console.log('log once'));
|
|
1621
|
+
|
|
1622
|
+
// Returns a new Array with a function `onceWrapper` which has a property
|
|
1623
|
+
// `listener` which contains the original listener bound above
|
|
1624
|
+
const listeners = emitter.rawListeners('log');
|
|
1625
|
+
const logFnWrapper = listeners[0];
|
|
1626
|
+
|
|
1627
|
+
// Logs "log once" to the console and does not unbind the `once` event
|
|
1628
|
+
logFnWrapper.listener();
|
|
1629
|
+
|
|
1630
|
+
// Logs "log once" to the console and removes the listener
|
|
1631
|
+
logFnWrapper();
|
|
1632
|
+
|
|
1633
|
+
emitter.on('log', () => console.log('log persistently'));
|
|
1634
|
+
// Will return a new Array with a single function bound by `.on()` above
|
|
1635
|
+
const newListeners = emitter.rawListeners('log');
|
|
1636
|
+
|
|
1637
|
+
// Logs "log persistently" twice
|
|
1638
|
+
newListeners[0]();
|
|
1639
|
+
emitter.emit('log');
|
|
1640
|
+
```
|
|
1641
|
+
|
|
1642
|
+
##### Type Parameters
|
|
1643
|
+
|
|
1644
|
+
###### E
|
|
1645
|
+
|
|
1646
|
+
`E` *extends* keyof `WritableEventMap`
|
|
1647
|
+
|
|
1648
|
+
##### Parameters
|
|
1649
|
+
|
|
1650
|
+
###### eventName
|
|
1651
|
+
|
|
1652
|
+
`E`
|
|
1653
|
+
|
|
1654
|
+
##### Returns
|
|
1655
|
+
|
|
1656
|
+
(...`args`) => `void`[]
|
|
1657
|
+
|
|
1658
|
+
##### Since
|
|
1659
|
+
|
|
1660
|
+
v9.4.0
|
|
1661
|
+
|
|
1662
|
+
##### Inherited from
|
|
1663
|
+
|
|
1664
|
+
`Transport.rawListeners`
|
|
1665
|
+
|
|
1666
|
+
#### Call Signature
|
|
1667
|
+
|
|
1668
|
+
> **rawListeners**(`eventName`): (...`args`) => `void`[]
|
|
1669
|
+
|
|
1670
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1050
|
|
1671
|
+
|
|
1672
|
+
##### Parameters
|
|
1673
|
+
|
|
1674
|
+
###### eventName
|
|
1675
|
+
|
|
1676
|
+
`string` \| `symbol`
|
|
1677
|
+
|
|
1678
|
+
##### Returns
|
|
1679
|
+
|
|
1680
|
+
(...`args`) => `void`[]
|
|
1681
|
+
|
|
1682
|
+
##### Inherited from
|
|
1683
|
+
|
|
1684
|
+
`Transport.rawListeners`
|
|
1685
|
+
|
|
1686
|
+
***
|
|
1687
|
+
|
|
1688
|
+
### removeAllListeners()
|
|
1689
|
+
|
|
1690
|
+
#### Call Signature
|
|
1691
|
+
|
|
1692
|
+
> **removeAllListeners**\<`E`\>(`eventName?`): `this`
|
|
1693
|
+
|
|
1694
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1052
|
|
1695
|
+
|
|
1696
|
+
Removes all listeners, or those of the specified `eventName`.
|
|
1697
|
+
|
|
1698
|
+
It is bad practice to remove listeners added elsewhere in the code,
|
|
1699
|
+
particularly when the `EventEmitter` instance was created by some other
|
|
1700
|
+
component or module (e.g. sockets or file streams).
|
|
1701
|
+
|
|
1702
|
+
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
1703
|
+
|
|
1704
|
+
##### Type Parameters
|
|
1705
|
+
|
|
1706
|
+
###### E
|
|
1707
|
+
|
|
1708
|
+
`E` *extends* keyof `WritableEventMap`
|
|
1709
|
+
|
|
1710
|
+
##### Parameters
|
|
1711
|
+
|
|
1712
|
+
###### eventName?
|
|
1713
|
+
|
|
1714
|
+
`E`
|
|
1715
|
+
|
|
1716
|
+
##### Returns
|
|
1717
|
+
|
|
1718
|
+
`this`
|
|
1719
|
+
|
|
1720
|
+
##### Since
|
|
1721
|
+
|
|
1722
|
+
v0.1.26
|
|
1723
|
+
|
|
1724
|
+
##### Inherited from
|
|
1725
|
+
|
|
1726
|
+
`Transport.removeAllListeners`
|
|
1727
|
+
|
|
1728
|
+
#### Call Signature
|
|
1729
|
+
|
|
1730
|
+
> **removeAllListeners**(`eventName?`): `this`
|
|
1731
|
+
|
|
1732
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1053
|
|
1733
|
+
|
|
1734
|
+
##### Parameters
|
|
1735
|
+
|
|
1736
|
+
###### eventName?
|
|
1737
|
+
|
|
1738
|
+
`string` \| `symbol`
|
|
1739
|
+
|
|
1740
|
+
##### Returns
|
|
1741
|
+
|
|
1742
|
+
`this`
|
|
1743
|
+
|
|
1744
|
+
##### Inherited from
|
|
1745
|
+
|
|
1746
|
+
`Transport.removeAllListeners`
|
|
1747
|
+
|
|
1748
|
+
***
|
|
1749
|
+
|
|
1750
|
+
### removeListener()
|
|
1751
|
+
|
|
1752
|
+
#### Call Signature
|
|
1753
|
+
|
|
1754
|
+
> **removeListener**\<`E`\>(`eventName`, `listener`): `this`
|
|
1755
|
+
|
|
1756
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1054
|
|
1757
|
+
|
|
1758
|
+
Removes the specified `listener` from the listener array for the event named
|
|
1759
|
+
`eventName`.
|
|
1760
|
+
|
|
1761
|
+
```js
|
|
1762
|
+
const callback = (stream) => {
|
|
1763
|
+
console.log('someone connected!');
|
|
1764
|
+
};
|
|
1765
|
+
server.on('connection', callback);
|
|
1766
|
+
// ...
|
|
1767
|
+
server.removeListener('connection', callback);
|
|
1768
|
+
```
|
|
1769
|
+
|
|
1770
|
+
`removeListener()` will remove, at most, one instance of a listener from the
|
|
1771
|
+
listener array. If any single listener has been added multiple times to the
|
|
1772
|
+
listener array for the specified `eventName`, then `removeListener()` must be
|
|
1773
|
+
called multiple times to remove each instance.
|
|
1774
|
+
|
|
1775
|
+
Once an event is emitted, all listeners attached to it at the
|
|
1776
|
+
time of emitting are called in order. This implies that any
|
|
1777
|
+
`removeListener()` or `removeAllListeners()` calls _after_ emitting and
|
|
1778
|
+
_before_ the last listener finishes execution will not remove them from
|
|
1779
|
+
`emit()` in progress. Subsequent events behave as expected.
|
|
1780
|
+
|
|
1781
|
+
```js
|
|
1782
|
+
import { EventEmitter } from 'node:events';
|
|
1783
|
+
class MyEmitter extends EventEmitter {}
|
|
1784
|
+
const myEmitter = new MyEmitter();
|
|
1785
|
+
|
|
1786
|
+
const callbackA = () => {
|
|
1787
|
+
console.log('A');
|
|
1788
|
+
myEmitter.removeListener('event', callbackB);
|
|
1789
|
+
};
|
|
1790
|
+
|
|
1791
|
+
const callbackB = () => {
|
|
1792
|
+
console.log('B');
|
|
1793
|
+
};
|
|
1794
|
+
|
|
1795
|
+
myEmitter.on('event', callbackA);
|
|
1796
|
+
|
|
1797
|
+
myEmitter.on('event', callbackB);
|
|
1798
|
+
|
|
1799
|
+
// callbackA removes listener callbackB but it will still be called.
|
|
1800
|
+
// Internal listener array at time of emit [callbackA, callbackB]
|
|
1801
|
+
myEmitter.emit('event');
|
|
1802
|
+
// Prints:
|
|
1803
|
+
// A
|
|
1804
|
+
// B
|
|
1805
|
+
|
|
1806
|
+
// callbackB is now removed.
|
|
1807
|
+
// Internal listener array [callbackA]
|
|
1808
|
+
myEmitter.emit('event');
|
|
1809
|
+
// Prints:
|
|
1810
|
+
// A
|
|
1811
|
+
```
|
|
1812
|
+
|
|
1813
|
+
Because listeners are managed using an internal array, calling this will
|
|
1814
|
+
change the position indexes of any listener registered _after_ the listener
|
|
1815
|
+
being removed. This will not impact the order in which listeners are called,
|
|
1816
|
+
but it means that any copies of the listener array as returned by
|
|
1817
|
+
the `emitter.listeners()` method will need to be recreated.
|
|
1818
|
+
|
|
1819
|
+
When a single function has been added as a handler multiple times for a single
|
|
1820
|
+
event (as in the example below), `removeListener()` will remove the most
|
|
1821
|
+
recently added instance. In the example the `once('ping')`
|
|
1822
|
+
listener is removed:
|
|
1823
|
+
|
|
1824
|
+
```js
|
|
1825
|
+
import { EventEmitter } from 'node:events';
|
|
1826
|
+
const ee = new EventEmitter();
|
|
1827
|
+
|
|
1828
|
+
function pong() {
|
|
1829
|
+
console.log('pong');
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
ee.on('ping', pong);
|
|
1833
|
+
ee.once('ping', pong);
|
|
1834
|
+
ee.removeListener('ping', pong);
|
|
1835
|
+
|
|
1836
|
+
ee.emit('ping');
|
|
1837
|
+
ee.emit('ping');
|
|
1838
|
+
```
|
|
1839
|
+
|
|
1840
|
+
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
1841
|
+
|
|
1842
|
+
##### Type Parameters
|
|
1843
|
+
|
|
1844
|
+
###### E
|
|
1845
|
+
|
|
1846
|
+
`E` *extends* keyof `WritableEventMap`
|
|
1847
|
+
|
|
1848
|
+
##### Parameters
|
|
1849
|
+
|
|
1850
|
+
###### eventName
|
|
1851
|
+
|
|
1852
|
+
`E`
|
|
1853
|
+
|
|
1854
|
+
###### listener
|
|
1855
|
+
|
|
1856
|
+
(...`args`) => `void`
|
|
1857
|
+
|
|
1858
|
+
##### Returns
|
|
1859
|
+
|
|
1860
|
+
`this`
|
|
1861
|
+
|
|
1862
|
+
##### Since
|
|
1863
|
+
|
|
1864
|
+
v0.1.26
|
|
1865
|
+
|
|
1866
|
+
##### Inherited from
|
|
1867
|
+
|
|
1868
|
+
`Transport.removeListener`
|
|
1869
|
+
|
|
1870
|
+
#### Call Signature
|
|
1871
|
+
|
|
1872
|
+
> **removeListener**(`eventName`, `listener`): `this`
|
|
1873
|
+
|
|
1874
|
+
Defined in: node\_modules/@types/node/stream.d.ts:1058
|
|
1875
|
+
|
|
1876
|
+
##### Parameters
|
|
1877
|
+
|
|
1878
|
+
###### eventName
|
|
1879
|
+
|
|
1880
|
+
`string` \| `symbol`
|
|
1881
|
+
|
|
1882
|
+
###### listener
|
|
1883
|
+
|
|
1884
|
+
(...`args`) => `void`
|
|
1885
|
+
|
|
1886
|
+
##### Returns
|
|
1887
|
+
|
|
1888
|
+
`this`
|
|
1889
|
+
|
|
1890
|
+
##### Inherited from
|
|
1891
|
+
|
|
1892
|
+
`Transport.removeListener`
|
|
1893
|
+
|
|
1894
|
+
***
|
|
1895
|
+
|
|
1896
|
+
### setDefaultEncoding()
|
|
1897
|
+
|
|
1898
|
+
> **setDefaultEncoding**(`encoding`): `this`
|
|
1899
|
+
|
|
1900
|
+
Defined in: node\_modules/@types/node/stream.d.ts:903
|
|
1901
|
+
|
|
1902
|
+
The `writable.setDefaultEncoding()` method sets the default `encoding` for a `Writable` stream.
|
|
1903
|
+
|
|
1904
|
+
#### Parameters
|
|
1905
|
+
|
|
1906
|
+
##### encoding
|
|
1907
|
+
|
|
1908
|
+
`BufferEncoding`
|
|
1909
|
+
|
|
1910
|
+
The new default encoding
|
|
1911
|
+
|
|
1912
|
+
#### Returns
|
|
1913
|
+
|
|
1914
|
+
`this`
|
|
1915
|
+
|
|
1916
|
+
#### Since
|
|
1917
|
+
|
|
1918
|
+
v0.11.15
|
|
1919
|
+
|
|
1920
|
+
#### Inherited from
|
|
1921
|
+
|
|
1922
|
+
`Transport.setDefaultEncoding`
|
|
1923
|
+
|
|
1924
|
+
***
|
|
1925
|
+
|
|
1926
|
+
### setMaxListeners()
|
|
1927
|
+
|
|
1928
|
+
> **setMaxListeners**(`n`): `this`
|
|
1929
|
+
|
|
1930
|
+
Defined in: node\_modules/@types/node/events.d.ts:436
|
|
1931
|
+
|
|
1932
|
+
By default `EventEmitter`s will print a warning if more than `10` listeners are
|
|
1933
|
+
added for a particular event. This is a useful default that helps finding
|
|
1934
|
+
memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
|
|
1935
|
+
modified for this specific `EventEmitter` instance. The value can be set to
|
|
1936
|
+
`Infinity` (or `0`) to indicate an unlimited number of listeners.
|
|
1937
|
+
|
|
1938
|
+
Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
1939
|
+
|
|
1940
|
+
#### Parameters
|
|
1941
|
+
|
|
1942
|
+
##### n
|
|
1943
|
+
|
|
1944
|
+
`number`
|
|
1945
|
+
|
|
1946
|
+
#### Returns
|
|
1947
|
+
|
|
1948
|
+
`this`
|
|
1949
|
+
|
|
1950
|
+
#### Since
|
|
1951
|
+
|
|
1952
|
+
v0.3.5
|
|
1953
|
+
|
|
1954
|
+
#### Inherited from
|
|
1955
|
+
|
|
1956
|
+
`Transport.setMaxListeners`
|
|
1957
|
+
|
|
1958
|
+
***
|
|
1959
|
+
|
|
1960
|
+
### uncork()
|
|
1961
|
+
|
|
1962
|
+
> **uncork**(): `void`
|
|
1963
|
+
|
|
1964
|
+
Defined in: node\_modules/@types/node/stream.d.ts:991
|
|
1965
|
+
|
|
1966
|
+
The `writable.uncork()` method flushes all data buffered since [cork](#cork) was called.
|
|
1967
|
+
|
|
1968
|
+
When using `writable.cork()` and `writable.uncork()` to manage the buffering
|
|
1969
|
+
of writes to a stream, defer calls to `writable.uncork()` using `process.nextTick()`. Doing so allows batching of all `writable.write()` calls that occur within a given Node.js event
|
|
1970
|
+
loop phase.
|
|
1971
|
+
|
|
1972
|
+
```js
|
|
1973
|
+
stream.cork();
|
|
1974
|
+
stream.write('some ');
|
|
1975
|
+
stream.write('data ');
|
|
1976
|
+
process.nextTick(() => stream.uncork());
|
|
1977
|
+
```
|
|
1978
|
+
|
|
1979
|
+
If the `writable.cork()` method is called multiple times on a stream, the
|
|
1980
|
+
same number of calls to `writable.uncork()` must be called to flush the buffered
|
|
1981
|
+
data.
|
|
1982
|
+
|
|
1983
|
+
```js
|
|
1984
|
+
stream.cork();
|
|
1985
|
+
stream.write('some ');
|
|
1986
|
+
stream.cork();
|
|
1987
|
+
stream.write('data ');
|
|
1988
|
+
process.nextTick(() => {
|
|
1989
|
+
stream.uncork();
|
|
1990
|
+
// The data will not be flushed until uncork() is called a second time.
|
|
1991
|
+
stream.uncork();
|
|
1992
|
+
});
|
|
1993
|
+
```
|
|
1994
|
+
|
|
1995
|
+
See also: `writable.cork()`.
|
|
1996
|
+
|
|
1997
|
+
#### Returns
|
|
1998
|
+
|
|
1999
|
+
`void`
|
|
2000
|
+
|
|
2001
|
+
#### Since
|
|
2002
|
+
|
|
2003
|
+
v0.11.2
|
|
2004
|
+
|
|
2005
|
+
#### Inherited from
|
|
2006
|
+
|
|
2007
|
+
`Transport.uncork`
|
|
2008
|
+
|
|
2009
|
+
***
|
|
2010
|
+
|
|
2011
|
+
### write()
|
|
2012
|
+
|
|
2013
|
+
#### Call Signature
|
|
2014
|
+
|
|
2015
|
+
> **write**(`chunk`, `callback?`): `boolean`
|
|
2016
|
+
|
|
2017
|
+
Defined in: node\_modules/@types/node/stream.d.ts:886
|
|
2018
|
+
|
|
2019
|
+
The `writable.write()` method writes some data to the stream, and calls the
|
|
2020
|
+
supplied `callback` once the data has been fully handled. If an error
|
|
2021
|
+
occurs, the `callback` will be called with the error as its
|
|
2022
|
+
first argument. The `callback` is called asynchronously and before `'error'` is
|
|
2023
|
+
emitted.
|
|
2024
|
+
|
|
2025
|
+
The return value is `true` if the internal buffer is less than the `highWaterMark` configured when the stream was created after admitting `chunk`.
|
|
2026
|
+
If `false` is returned, further attempts to write data to the stream should
|
|
2027
|
+
stop until the `'drain'` event is emitted.
|
|
2028
|
+
|
|
2029
|
+
While a stream is not draining, calls to `write()` will buffer `chunk`, and
|
|
2030
|
+
return false. Once all currently buffered chunks are drained (accepted for
|
|
2031
|
+
delivery by the operating system), the `'drain'` event will be emitted.
|
|
2032
|
+
Once `write()` returns false, do not write more chunks
|
|
2033
|
+
until the `'drain'` event is emitted. While calling `write()` on a stream that
|
|
2034
|
+
is not draining is allowed, Node.js will buffer all written chunks until
|
|
2035
|
+
maximum memory usage occurs, at which point it will abort unconditionally.
|
|
2036
|
+
Even before it aborts, high memory usage will cause poor garbage collector
|
|
2037
|
+
performance and high RSS (which is not typically released back to the system,
|
|
2038
|
+
even after the memory is no longer required). Since TCP sockets may never
|
|
2039
|
+
drain if the remote peer does not read the data, writing a socket that is
|
|
2040
|
+
not draining may lead to a remotely exploitable vulnerability.
|
|
2041
|
+
|
|
2042
|
+
Writing data while the stream is not draining is particularly
|
|
2043
|
+
problematic for a `Transform`, because the `Transform` streams are paused
|
|
2044
|
+
by default until they are piped or a `'data'` or `'readable'` event handler
|
|
2045
|
+
is added.
|
|
2046
|
+
|
|
2047
|
+
If the data to be written can be generated or fetched on demand, it is
|
|
2048
|
+
recommended to encapsulate the logic into a `Readable` and use [pipe](#pipe). However, if calling `write()` is preferred, it is
|
|
2049
|
+
possible to respect backpressure and avoid memory issues using the `'drain'` event:
|
|
2050
|
+
|
|
2051
|
+
```js
|
|
2052
|
+
function write(data, cb) {
|
|
2053
|
+
if (!stream.write(data)) {
|
|
2054
|
+
stream.once('drain', cb);
|
|
2055
|
+
} else {
|
|
2056
|
+
process.nextTick(cb);
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
// Wait for cb to be called before doing any other write.
|
|
2061
|
+
write('hello', () => {
|
|
2062
|
+
console.log('Write completed, do more writes now.');
|
|
2063
|
+
});
|
|
2064
|
+
```
|
|
2065
|
+
|
|
2066
|
+
A `Writable` stream in object mode will always ignore the `encoding` argument.
|
|
2067
|
+
|
|
2068
|
+
##### Parameters
|
|
2069
|
+
|
|
2070
|
+
###### chunk
|
|
2071
|
+
|
|
2072
|
+
`any`
|
|
2073
|
+
|
|
2074
|
+
Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
|
|
2075
|
+
{TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
|
|
2076
|
+
|
|
2077
|
+
###### callback?
|
|
2078
|
+
|
|
2079
|
+
(`error`) => `void`
|
|
2080
|
+
|
|
2081
|
+
Callback for when this chunk of data is flushed.
|
|
2082
|
+
|
|
2083
|
+
##### Returns
|
|
2084
|
+
|
|
2085
|
+
`boolean`
|
|
2086
|
+
|
|
2087
|
+
`false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
|
2088
|
+
|
|
2089
|
+
##### Since
|
|
2090
|
+
|
|
2091
|
+
v0.9.4
|
|
2092
|
+
|
|
2093
|
+
##### Inherited from
|
|
2094
|
+
|
|
2095
|
+
`Transport.write`
|
|
2096
|
+
|
|
2097
|
+
#### Call Signature
|
|
2098
|
+
|
|
2099
|
+
> **write**(`chunk`, `encoding`, `callback?`): `boolean`
|
|
2100
|
+
|
|
2101
|
+
Defined in: node\_modules/@types/node/stream.d.ts:897
|
|
2102
|
+
|
|
2103
|
+
Writes data to the stream, with an explicit encoding for string data.
|
|
2104
|
+
|
|
2105
|
+
##### Parameters
|
|
2106
|
+
|
|
2107
|
+
###### chunk
|
|
2108
|
+
|
|
2109
|
+
`any`
|
|
2110
|
+
|
|
2111
|
+
Optional data to write. For streams not operating in object mode, `chunk` must be a {string}, {Buffer},
|
|
2112
|
+
{TypedArray} or {DataView}. For object mode streams, `chunk` may be any JavaScript value other than `null`.
|
|
2113
|
+
|
|
2114
|
+
###### encoding
|
|
2115
|
+
|
|
2116
|
+
`BufferEncoding`
|
|
2117
|
+
|
|
2118
|
+
The encoding, if `chunk` is a string.
|
|
2119
|
+
|
|
2120
|
+
###### callback?
|
|
2121
|
+
|
|
2122
|
+
(`error`) => `void`
|
|
2123
|
+
|
|
2124
|
+
Callback for when this chunk of data is flushed.
|
|
2125
|
+
|
|
2126
|
+
##### Returns
|
|
2127
|
+
|
|
2128
|
+
`boolean`
|
|
2129
|
+
|
|
2130
|
+
`false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
|
2131
|
+
|
|
2132
|
+
##### See
|
|
2133
|
+
|
|
2134
|
+
Writable.write for full details.
|
|
2135
|
+
|
|
2136
|
+
##### Since
|
|
2137
|
+
|
|
2138
|
+
v0.9.4
|
|
2139
|
+
|
|
2140
|
+
##### Inherited from
|
|
2141
|
+
|
|
2142
|
+
`Transport.write`
|
|
2143
|
+
|
|
2144
|
+
***
|
|
2145
|
+
|
|
2146
|
+
### fromWeb()
|
|
2147
|
+
|
|
2148
|
+
> `static` **fromWeb**(`writableStream`, `options?`): `Writable`
|
|
2149
|
+
|
|
2150
|
+
Defined in: node\_modules/@types/node/stream.d.ts:746
|
|
2151
|
+
|
|
2152
|
+
A utility method for creating a `Writable` from a web `WritableStream`.
|
|
2153
|
+
|
|
2154
|
+
#### Parameters
|
|
2155
|
+
|
|
2156
|
+
##### writableStream
|
|
2157
|
+
|
|
2158
|
+
`WritableStream`
|
|
2159
|
+
|
|
2160
|
+
##### options?
|
|
2161
|
+
|
|
2162
|
+
`Pick`\<`WritableOptions`\<`Writable`\>, `"signal"` \| `"highWaterMark"` \| `"objectMode"` \| `"decodeStrings"`\>
|
|
2163
|
+
|
|
2164
|
+
#### Returns
|
|
2165
|
+
|
|
2166
|
+
`Writable`
|
|
2167
|
+
|
|
2168
|
+
#### Since
|
|
2169
|
+
|
|
2170
|
+
v17.0.0
|
|
2171
|
+
|
|
2172
|
+
#### Inherited from
|
|
2173
|
+
|
|
2174
|
+
`Transport.fromWeb`
|
|
2175
|
+
|
|
2176
|
+
***
|
|
2177
|
+
|
|
2178
|
+
### toWeb()
|
|
2179
|
+
|
|
2180
|
+
> `static` **toWeb**(`streamWritable`): `WritableStream`
|
|
2181
|
+
|
|
2182
|
+
Defined in: node\_modules/@types/node/stream.d.ts:754
|
|
2183
|
+
|
|
2184
|
+
A utility method for creating a web `WritableStream` from a `Writable`.
|
|
2185
|
+
|
|
2186
|
+
#### Parameters
|
|
2187
|
+
|
|
2188
|
+
##### streamWritable
|
|
2189
|
+
|
|
2190
|
+
`WritableStream`
|
|
2191
|
+
|
|
2192
|
+
#### Returns
|
|
2193
|
+
|
|
2194
|
+
`WritableStream`
|
|
2195
|
+
|
|
2196
|
+
#### Since
|
|
2197
|
+
|
|
2198
|
+
v17.0.0
|
|
2199
|
+
|
|
2200
|
+
#### Inherited from
|
|
2201
|
+
|
|
2202
|
+
`Transport.toWeb`
|