@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,172 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { AccessControlList } from "../security/AccessControlList.js";
|
|
3
|
+
/**
|
|
4
|
+
* Indicates a provided function or list of functions to execute *after* the decorated function and before the response
|
|
5
|
+
* is sent to a client. Note that the function must call `next()` in order for this decorator to work.
|
|
6
|
+
*
|
|
7
|
+
* @param func The function or list of functions to execute *after* the decorated function.
|
|
8
|
+
*/
|
|
9
|
+
export declare function After(func: Function | string | (Function | string)[]): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Applies PassportJS authentication to the decorated route or method for the provided strategy or list of strategies
|
|
12
|
+
* should be attempted before processing the route.
|
|
13
|
+
*
|
|
14
|
+
* @param strategies The PassportJS strategies that will be applied when incoming requests are processed.
|
|
15
|
+
* @param require Set to `true` to indicate that at least one of the specified authentication strategies must pass to
|
|
16
|
+
* proceed, otherwise set to `false`. Default is `true`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function Auth(strategies: string | string[], require?: boolean): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Injects the authenticated authentication result as the value of the decorated argument.
|
|
21
|
+
*/
|
|
22
|
+
export declare function AuthResult(target: any, propertyKey: string, index: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Indicates a provided function or list of functions to execute *before* the decorated function.
|
|
25
|
+
*
|
|
26
|
+
* @param func The function or list of functions to execute *before* the decorated function.
|
|
27
|
+
*/
|
|
28
|
+
export declare function Before(func: Function | string | (Function | string)[]): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Indicates that the decorated function will return content encoded with the specified content type.
|
|
31
|
+
*
|
|
32
|
+
* @param type The content type that the function will return.
|
|
33
|
+
*/
|
|
34
|
+
export declare function ContentType(type: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Indicates that the decorated function handles incoming `DELETE` requests at the given sub-path.
|
|
37
|
+
*
|
|
38
|
+
* @param path The sub-path that the route will handle requests for.
|
|
39
|
+
*/
|
|
40
|
+
export declare function Delete(path?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Indicates that the decorated function handles incoming `GET` requests at the given sub-path.
|
|
43
|
+
*
|
|
44
|
+
* @param path The sub-path that the route will handle requests for.
|
|
45
|
+
*/
|
|
46
|
+
export declare function Get(path?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Indicates that the decorated function handles incoming `HEAD` requests at the given sub-path.
|
|
49
|
+
*
|
|
50
|
+
* @param path The sub-path that the route will handle requests for.
|
|
51
|
+
*/
|
|
52
|
+
export declare function Head(path?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Injects the value of the specified request header with the given name as the value of the decorated argument.
|
|
55
|
+
*
|
|
56
|
+
* @param name The name of the header whose value will be injected.
|
|
57
|
+
*/
|
|
58
|
+
export declare function Header(name: string): (target: any, propertyKey: string, index: number) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Indicates that the decorated function handles incoming HTTP requests for the specified HTTP method(s) at the given sub-path.
|
|
61
|
+
*
|
|
62
|
+
* @param method The HTTP method(s) to handle requests for.
|
|
63
|
+
* @param path The sub-path that the route handles requests for.
|
|
64
|
+
*/
|
|
65
|
+
export declare function Method(method: string | string[], path?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Indicates that the class utilizes is a manager for the specified class type.
|
|
68
|
+
*
|
|
69
|
+
* @param type The data model class type to associate the class with.
|
|
70
|
+
*/
|
|
71
|
+
export declare function Model(type: any): <T extends {
|
|
72
|
+
new (...args: any[]): {};
|
|
73
|
+
}>(constructor: T) => {
|
|
74
|
+
new (...args: any[]): {};
|
|
75
|
+
/** The class type of the data model type associated with this class. */
|
|
76
|
+
readonly modelClass: any;
|
|
77
|
+
} & T;
|
|
78
|
+
/**
|
|
79
|
+
* Indicates that the decorated function handles incoming `OPTIONS` requests at the given sub-path.
|
|
80
|
+
*
|
|
81
|
+
* @param path The sub-path that the route will handle requests for.
|
|
82
|
+
*/
|
|
83
|
+
export declare function Options(path?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Injects the value of the specified URI parameter with the given name as the value of the decorated argument. If no
|
|
86
|
+
* name is specified the entire request parameter will be injected.
|
|
87
|
+
*
|
|
88
|
+
* @param name The name of the URI parameter whose value will be injected.
|
|
89
|
+
*/
|
|
90
|
+
export declare function Param(name?: string | undefined): (target: any, propertyKey: string, index: number) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Indicates that the decorated function handles incoming `PATCH` requests at the given sub-path.
|
|
93
|
+
*
|
|
94
|
+
* @param path The sub-path that the route will handle requests for.
|
|
95
|
+
*/
|
|
96
|
+
export declare function Patch(path?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Indicates that the decorated function handles incoming `POST` requests at the given sub-path.
|
|
99
|
+
*
|
|
100
|
+
* @param path The sub-path that the route will handle requests for.
|
|
101
|
+
*/
|
|
102
|
+
export declare function Post(path?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
103
|
+
/**
|
|
104
|
+
* Indicates that the decorated function handles incoming `PUT` requests at the given sub-path.
|
|
105
|
+
*
|
|
106
|
+
* @param path The sub-path that the route will handle requests for.
|
|
107
|
+
*/
|
|
108
|
+
export declare function Put(path?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
109
|
+
type PartialACL = Partial<AccessControlList> & Pick<AccessControlList, "records">;
|
|
110
|
+
/**
|
|
111
|
+
* Apply this to any route handler class or an individual route handler function to indicate that it should be
|
|
112
|
+
* protected by the AccessControlList security system. The `acl` parameter specifies the ACL governing access
|
|
113
|
+
* to the HTTP resource(s) defined. If a class and a given route handler function both have this decorator
|
|
114
|
+
* applied, the class ACL will be listed as the parent to the function's ACL object, thus inheriting
|
|
115
|
+
* whatever permissions applied to the class level.
|
|
116
|
+
*
|
|
117
|
+
* @param acl The access control list to define for this route class or handler. Not specifying a value here
|
|
118
|
+
* * will default to the behavior of denying anonymous access to the resource and allowing any authenticated
|
|
119
|
+
* * user CRUD access.
|
|
120
|
+
*/
|
|
121
|
+
export declare function Protect(acl?: PartialACL): (target: any, propertyKey?: string) => void;
|
|
122
|
+
/**
|
|
123
|
+
* Injects the value of the specified query parameter with the given name as the value of the decorated argument. If
|
|
124
|
+
* no name is specified the entire request query will be injected.
|
|
125
|
+
*
|
|
126
|
+
* @param name THe name of the query parameter whose value will be injected.
|
|
127
|
+
*/
|
|
128
|
+
export declare function Query(name?: string | undefined): (target: any, propertyKey: string, index: number) => void;
|
|
129
|
+
/**
|
|
130
|
+
* Injects the Express request object as the value of the decorated argument.
|
|
131
|
+
*/
|
|
132
|
+
export declare function Request(target: any, propertyKey: string, index: number): void;
|
|
133
|
+
/**
|
|
134
|
+
* Injects the Express response object as the value of the decorated argument.
|
|
135
|
+
*/
|
|
136
|
+
export declare function Response(target: any, propertyKey: string, index: number): void;
|
|
137
|
+
/**
|
|
138
|
+
* Indicates that the client must be an authenticated user with at least one of the specified role(s) to process the
|
|
139
|
+
* request.
|
|
140
|
+
*
|
|
141
|
+
* @param roles The role(s) that an authenticated user must have to make the request.
|
|
142
|
+
*/
|
|
143
|
+
export declare function RequiresRole(roles: string | string[]): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
144
|
+
/**
|
|
145
|
+
* Indicates that the decorated class contains Express route definitions.
|
|
146
|
+
*
|
|
147
|
+
* @param paths The base path(s) that all route definitions will use.
|
|
148
|
+
*/
|
|
149
|
+
export declare function Route(paths: string | string[]): (target: Function) => void;
|
|
150
|
+
/**
|
|
151
|
+
* Injects the underlying Socket object associated with the request as the value of the decorated argument.
|
|
152
|
+
* When the handler function is for a WebSocket request, the returned socket will be the newly established
|
|
153
|
+
* WebSocket connection.
|
|
154
|
+
*/
|
|
155
|
+
export declare function Socket(target: any, propertyKey: string, index: number): void;
|
|
156
|
+
/**
|
|
157
|
+
* Injects the authenticated user object as the value of the decorated argument.
|
|
158
|
+
*/
|
|
159
|
+
export declare function User(target: any, propertyKey: string, index: number): void;
|
|
160
|
+
/**
|
|
161
|
+
* Indicates a validation function to execute in order to verify an incoming requests payload.
|
|
162
|
+
*
|
|
163
|
+
* @param func The validation function to execute that will verify the request payload.
|
|
164
|
+
*/
|
|
165
|
+
export declare function Validate(func: Function | string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
166
|
+
/**
|
|
167
|
+
* Indicates that the decorated function handles incoming `WebSocket` upgrade requests at the given sub-path.
|
|
168
|
+
*
|
|
169
|
+
* @param path The sub-path that the route will handle requests for.
|
|
170
|
+
*/
|
|
171
|
+
export declare function WebSocket(path?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
172
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as DatabaseDecorators from "./DatabaseDecorators.js";
|
|
2
|
+
export * as DocDecorators from "./DocDecorators.js";
|
|
3
|
+
export * as EventDecorators from "./EventDecorators.js";
|
|
4
|
+
export * as ModelDecorators from "./ModelDecorators.js";
|
|
5
|
+
export * as PersistenceDecorators from "./PersistenceDecorators.js";
|
|
6
|
+
export * as RouteDecorators from "./RouteDecorators.js";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { HttpRequest, HttpResponse } from "./types.js";
|
|
2
|
+
import type { HttpRequest as UWSHttpRequest, HttpResponse as UWSHttpResponse } from "uWebSockets.js";
|
|
3
|
+
/**
|
|
4
|
+
* Adapts a uWS `HttpRequest` to the framework-agnostic `HttpRequest` interface.
|
|
5
|
+
*
|
|
6
|
+
* IMPORTANT: uWS HttpRequest is stack-allocated and only valid during the synchronous portion of
|
|
7
|
+
* the handler. All request data MUST be captured in the constructor before any `await`.
|
|
8
|
+
*/
|
|
9
|
+
export declare class UWSRequest implements HttpRequest {
|
|
10
|
+
readonly method: string;
|
|
11
|
+
readonly url: string;
|
|
12
|
+
readonly path: string;
|
|
13
|
+
readonly headers: Record<string, string>;
|
|
14
|
+
params: Record<string, string>;
|
|
15
|
+
readonly query: Record<string, string | string[]>;
|
|
16
|
+
body: any;
|
|
17
|
+
rawBody?: Buffer;
|
|
18
|
+
readonly cookies: Record<string, string>;
|
|
19
|
+
readonly signedCookies: Record<string, string>;
|
|
20
|
+
readonly socket: {
|
|
21
|
+
remoteAddress?: string;
|
|
22
|
+
};
|
|
23
|
+
user?: any;
|
|
24
|
+
authPayload?: any;
|
|
25
|
+
authToken?: string;
|
|
26
|
+
/** Allow arbitrary per-request properties (websocket, wsHandled, etc.) */
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
constructor(uwsReq: UWSHttpRequest, remoteAddress?: string);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Adapts a uWS `HttpResponse` to the framework-agnostic `HttpResponse` interface.
|
|
32
|
+
*
|
|
33
|
+
* Buffers headers and status code until the first write. Tracks abort state to safely
|
|
34
|
+
* skip writes on aborted connections. All uWS writes are wrapped in `res.cork()` for
|
|
35
|
+
* optimal performance.
|
|
36
|
+
*/
|
|
37
|
+
export declare class UWSResponse implements HttpResponse {
|
|
38
|
+
private readonly uwsRes;
|
|
39
|
+
private _statusCode;
|
|
40
|
+
private _headers;
|
|
41
|
+
private _headersSent;
|
|
42
|
+
private _writableEnded;
|
|
43
|
+
private _aborted;
|
|
44
|
+
/** Set to true for HEAD requests — body bytes must not be sent. */
|
|
45
|
+
isHead: boolean;
|
|
46
|
+
/** Intermediate result passed between middleware. */
|
|
47
|
+
result?: any;
|
|
48
|
+
/** Allow arbitrary per-response properties. */
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
constructor(uwsRes: UWSHttpResponse);
|
|
51
|
+
get statusCode(): number;
|
|
52
|
+
get headersSent(): boolean;
|
|
53
|
+
get writableEnded(): boolean;
|
|
54
|
+
status(code: number): this;
|
|
55
|
+
setHeader(key: string, value: string | number): this;
|
|
56
|
+
getHeader(key: string): string | undefined;
|
|
57
|
+
json(data: any): void;
|
|
58
|
+
send(data?: any): void;
|
|
59
|
+
end(data?: any): void;
|
|
60
|
+
/** Converts a numeric status code to the "200 OK" string format uWS expects. */
|
|
61
|
+
private _statusToString;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Reads the full request body from a uWS response object as a Buffer.
|
|
65
|
+
* Body parsing (JSON / URL-encoded) is applied based on content-type and the result
|
|
66
|
+
* is cached on `req.body` / `req.rawBody`.
|
|
67
|
+
*/
|
|
68
|
+
export declare function readBody(uwsRes: UWSHttpResponse, req: UWSRequest): Promise<void>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import uWS from "uWebSockets.js";
|
|
2
|
+
import type { HttpRequest, HttpResponse, RequestHandler } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Runs an ordered array of middleware handlers sequentially, Express-style.
|
|
5
|
+
* Supports both 3-param `(req, res, next)` handlers and 4-param `(err, req, res, next)`
|
|
6
|
+
* error handlers. On error, execution skips to the next error handler.
|
|
7
|
+
*
|
|
8
|
+
* Each handler is awaited via a Promise that resolves when next() is called, not when
|
|
9
|
+
* the handler's return value resolves. This correctly handles: (1) sync handlers that
|
|
10
|
+
* call next() synchronously, (2) async handlers that return next() or await before
|
|
11
|
+
* calling it, and (3) sync handlers that schedule next() via callbacks such as
|
|
12
|
+
* setTimeout or socket.once. The chain terminates early when a handler ends the
|
|
13
|
+
* response without calling next().
|
|
14
|
+
*/
|
|
15
|
+
export declare function runChain(handlers: RequestHandler[], req: HttpRequest, res: HttpResponse): Promise<void>;
|
|
16
|
+
/** Result returned by a pre-upgrade WebSocket auth function. */
|
|
17
|
+
export type WsUpgradeAuthResult = {
|
|
18
|
+
user?: any;
|
|
19
|
+
authPayload?: any;
|
|
20
|
+
authToken?: string;
|
|
21
|
+
/** Set to `true` to reject the connection with HTTP 401 before the WebSocket handshake. */
|
|
22
|
+
reject?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Optional pre-upgrade auth function for WebSocket routes. Called synchronously inside the uWS
|
|
26
|
+
* `upgrade` callback — before the WebSocket handshake completes. Returning `{ reject: true }`
|
|
27
|
+
* sends an HTTP 401 and skips the upgrade entirely. Returning `{}` falls through to the
|
|
28
|
+
* post-upgrade message-based LOGIN flow. Returning `{ user, ... }` pre-authenticates the
|
|
29
|
+
* connection so clients that can send an Authorization header skip the LOGIN step.
|
|
30
|
+
*/
|
|
31
|
+
export type WsUpgradeAuth = (req: HttpRequest) => WsUpgradeAuthResult;
|
|
32
|
+
/**
|
|
33
|
+
* Thin Express-compatible wrapper over `uWS.TemplatedApp`.
|
|
34
|
+
*
|
|
35
|
+
* Provides the same `app.get()`, `app.post()`, `app.use()`, etc. API that
|
|
36
|
+
* `RouteUtils.registerRoute()` uses, so no changes are needed in route registration
|
|
37
|
+
* code. Global middleware registered via `use()` is prepended to every route's chain.
|
|
38
|
+
*
|
|
39
|
+
* Also supports:
|
|
40
|
+
* - `ws(path, handlers)` — native uWS WebSocket routing
|
|
41
|
+
* - `static(basePath)` — basic static file serving
|
|
42
|
+
* - `listen(host, port)` / `close()` — server lifecycle
|
|
43
|
+
*/
|
|
44
|
+
export declare class HttpRouter {
|
|
45
|
+
private readonly uwsApp;
|
|
46
|
+
private readonly globalMiddleware;
|
|
47
|
+
private listenSocket;
|
|
48
|
+
/**
|
|
49
|
+
* Number of global middleware items registered BEFORE the first route was added.
|
|
50
|
+
* -1 means no routes have been registered yet (preRouteCount not yet frozen).
|
|
51
|
+
*/
|
|
52
|
+
private preRouteCount;
|
|
53
|
+
/** The port the server is currently listening on (set after a successful `listen()` call). */
|
|
54
|
+
listenPort: number;
|
|
55
|
+
constructor(uwsApp: uWS.TemplatedApp);
|
|
56
|
+
/** Returns `true` if the server is currently listening. */
|
|
57
|
+
get isListening(): boolean;
|
|
58
|
+
/** Register global middleware that runs before every route handler. */
|
|
59
|
+
use(...handlers: RequestHandler[]): this;
|
|
60
|
+
/**
|
|
61
|
+
* Freezes the pre-route middleware count the first time a route is registered.
|
|
62
|
+
* All global middleware registered BEFORE this call is "pre-route" middleware;
|
|
63
|
+
* everything added after is "post-route" (error handlers, metrics, etc.).
|
|
64
|
+
*/
|
|
65
|
+
private capturePreRouteCount;
|
|
66
|
+
get(routePath: string, ...handlers: RequestHandler[]): this;
|
|
67
|
+
post(routePath: string, ...handlers: RequestHandler[]): this;
|
|
68
|
+
put(routePath: string, ...handlers: RequestHandler[]): this;
|
|
69
|
+
delete(routePath: string, ...handlers: RequestHandler[]): this;
|
|
70
|
+
patch(routePath: string, ...handlers: RequestHandler[]): this;
|
|
71
|
+
head(routePath: string, ...handlers: RequestHandler[]): this;
|
|
72
|
+
options(routePath: string, ...handlers: RequestHandler[]): this;
|
|
73
|
+
/**
|
|
74
|
+
* Registers a WebSocket route. Handlers follow the same `(req, res, next)` pattern
|
|
75
|
+
* as HTTP routes; they receive `req.websocket` containing the uWS WebSocket handle.
|
|
76
|
+
*
|
|
77
|
+
* `upgradeAuth` is an optional pre-upgrade auth function. When provided it runs synchronously
|
|
78
|
+
* inside the uWS `upgrade` callback before the handshake. If it returns `{ reject: true }`,
|
|
79
|
+
* an HTTP 401 is sent and the upgrade is aborted. If it returns `{ user, ... }`, those
|
|
80
|
+
* credentials are attached to the request so downstream middleware sees an authenticated user.
|
|
81
|
+
* If it returns `{}`, auth falls through to the post-upgrade message-based LOGIN flow.
|
|
82
|
+
*
|
|
83
|
+
* Both `path` and `path + "/"` are registered to avoid trailing-slash mismatch.
|
|
84
|
+
*/
|
|
85
|
+
ws(routePath: string, handlers: RequestHandler[], wsOptions?: Partial<uWS.WebSocketBehavior<any>>, upgradeAuth?: WsUpgradeAuth): this;
|
|
86
|
+
/**
|
|
87
|
+
* Serves static files from a directory via a wildcard GET route.
|
|
88
|
+
* Files not found on disk return 404.
|
|
89
|
+
*/
|
|
90
|
+
static(basePath: string): this;
|
|
91
|
+
/**
|
|
92
|
+
* Starts listening on the given host and port.
|
|
93
|
+
* Resolves when the server is ready; rejects if the port cannot be bound.
|
|
94
|
+
*/
|
|
95
|
+
listen(host: string, port: number): Promise<void>;
|
|
96
|
+
/** Closes the listen socket, stopping the server from accepting new connections. */
|
|
97
|
+
close(): void;
|
|
98
|
+
[key: string]: any;
|
|
99
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import { Duplex } from "stream";
|
|
3
|
+
import type { WebSocket } from "uWebSockets.js";
|
|
4
|
+
import type { HttpRequest } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* HTTP request type for handling WebSocket upgrade requests.
|
|
7
|
+
* Extends `HttpRequest` with WebSocket-specific properties set by the router
|
|
8
|
+
* after the uWS WebSocket connection is opened.
|
|
9
|
+
*/
|
|
10
|
+
export interface RequestWS extends HttpRequest {
|
|
11
|
+
/**
|
|
12
|
+
* The uWS WebSocket shim for this connection. Set on `open` after the upgrade.
|
|
13
|
+
*/
|
|
14
|
+
websocket: UWSWebSocketShim | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Indicates that the WebSocket handler has processed this connection and the
|
|
17
|
+
* connection should remain open. Set to `true` by `wrapMiddleware` when a
|
|
18
|
+
* decorated handler returns successfully.
|
|
19
|
+
*/
|
|
20
|
+
wsHandled: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Wraps a uWS `WebSocket` handle and exposes an EventEmitter-based API compatible
|
|
24
|
+
* with what route handlers (e.g. `AdminRoute`) expect.
|
|
25
|
+
*
|
|
26
|
+
* uWS WebSockets fire events via behavior callbacks on the route, not on the socket
|
|
27
|
+
* object itself. This shim bridges that gap by:
|
|
28
|
+
* - Forwarding `message` / `close` events from the route behavior to this emitter.
|
|
29
|
+
* - Exposing `send(data, cb?)` and `close(code?, reason?)` that delegate to uWS.
|
|
30
|
+
*
|
|
31
|
+
* The Router's `ws()` implementation stores the shim in `ws.getUserData()` so that
|
|
32
|
+
* behavior callbacks can call `shim.emit(...)`.
|
|
33
|
+
*/
|
|
34
|
+
export declare class UWSWebSocketShim extends EventEmitter {
|
|
35
|
+
private readonly _ws;
|
|
36
|
+
readyState: number;
|
|
37
|
+
constructor(ws: WebSocket<any>);
|
|
38
|
+
/**
|
|
39
|
+
* Sends data over the WebSocket connection.
|
|
40
|
+
* @param data The data to send.
|
|
41
|
+
* @param cb Optional callback invoked on completion or error.
|
|
42
|
+
*/
|
|
43
|
+
send(data: any, cb?: (err?: Error) => void): void;
|
|
44
|
+
/**
|
|
45
|
+
* Closes the WebSocket connection with an optional code and reason.
|
|
46
|
+
*/
|
|
47
|
+
close(code?: number, reason?: string): void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates a Node.js `Duplex` stream from a `UWSWebSocketShim`, compatible with the
|
|
51
|
+
* `createWebSocketStream` API from the `ws` library.
|
|
52
|
+
*
|
|
53
|
+
* Incoming WebSocket messages are pushed as readable data; writes to the stream are
|
|
54
|
+
* forwarded as WebSocket messages.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createWebSocketStream(shim: UWSWebSocketShim): Duplex;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { HttpRequest, HttpResponse, NextFunction, RequestHandler, ErrorHandler } from "./types.js";
|
|
2
|
+
export { UWSRequest, UWSResponse, readBody } from "./Adapters.js";
|
|
3
|
+
export { HttpRouter, runChain } from "./Router.js";
|
|
4
|
+
export type { WsUpgradeAuth, WsUpgradeAuthResult } from "./Router.js";
|
|
5
|
+
export type { RequestWS } from "./WebSocket.js";
|
|
6
|
+
export { UWSWebSocketShim, createWebSocketStream } from "./WebSocket.js";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-agnostic HTTP request interface. Mirrors the Express `Request` surface used throughout
|
|
3
|
+
* this codebase so that route handlers, middleware, and utilities require no changes when the
|
|
4
|
+
* underlying HTTP server changes.
|
|
5
|
+
*/
|
|
6
|
+
export interface HttpRequest {
|
|
7
|
+
method: string;
|
|
8
|
+
path: string;
|
|
9
|
+
url: string;
|
|
10
|
+
headers: Record<string, string | string[] | undefined>;
|
|
11
|
+
params: Record<string, string>;
|
|
12
|
+
query: Record<string, string | string[]>;
|
|
13
|
+
body: any;
|
|
14
|
+
rawBody?: Buffer;
|
|
15
|
+
cookies: Record<string, string>;
|
|
16
|
+
signedCookies: Record<string, string>;
|
|
17
|
+
/** Minimal socket interface; populated with remote address for IP extraction. */
|
|
18
|
+
socket: {
|
|
19
|
+
remoteAddress?: string;
|
|
20
|
+
};
|
|
21
|
+
/** Set by JWT auth middleware after successful token verification. */
|
|
22
|
+
user?: any;
|
|
23
|
+
/** Full decoded JWT payload, set by JWT auth middleware. */
|
|
24
|
+
authPayload?: any;
|
|
25
|
+
/** Raw JWT token string, set by JWT auth middleware. */
|
|
26
|
+
authToken?: string;
|
|
27
|
+
/** Allow arbitrary per-request properties (e.g. req.websocket, req.wsHandled). */
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Framework-agnostic HTTP response interface. Mirrors the Express `Response` surface used
|
|
32
|
+
* throughout this codebase.
|
|
33
|
+
*/
|
|
34
|
+
export interface HttpResponse {
|
|
35
|
+
statusCode: number;
|
|
36
|
+
headersSent: boolean;
|
|
37
|
+
writableEnded: boolean;
|
|
38
|
+
/** Intermediate result passed between middleware via res.result. */
|
|
39
|
+
result?: any;
|
|
40
|
+
status(code: number): this;
|
|
41
|
+
setHeader(key: string, value: string | number): this;
|
|
42
|
+
getHeader(key: string): string | undefined;
|
|
43
|
+
json(data: any): void;
|
|
44
|
+
send(data?: any): void;
|
|
45
|
+
end(data?: any): void;
|
|
46
|
+
/** Allow arbitrary per-response properties. */
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}
|
|
49
|
+
/** Standard Express-style next callback. Pass an error to trigger error handlers. */
|
|
50
|
+
export type NextFunction = (err?: any) => void;
|
|
51
|
+
/** Standard 3-param middleware function. */
|
|
52
|
+
export type RequestHandler = (req: HttpRequest, res: HttpResponse, next: NextFunction) => void | Promise<void>;
|
|
53
|
+
/** Standard 4-param error-handling middleware function. */
|
|
54
|
+
export type ErrorHandler = (err: any, req: HttpRequest, res: HttpResponse, next: NextFunction) => void | Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from "./ApiErrors.js";
|
|
2
|
+
export * from "./BackgroundService.js";
|
|
3
|
+
export * from "./BackgroundServiceManager.js";
|
|
4
|
+
export * from "./BulkError.js";
|
|
5
|
+
export * from "./EventListenerManager.js";
|
|
6
|
+
export * from "./NetUtils.js";
|
|
7
|
+
export * from "./NotificationUtils.js";
|
|
8
|
+
export * from "./ObjectFactory.js";
|
|
9
|
+
export * from "./OpenApiSpec.js";
|
|
10
|
+
export * from "./Server.js";
|
|
11
|
+
export * from "./Types.js";
|
|
12
|
+
export * from "./database/index.js";
|
|
13
|
+
export * from "./decorators/index.js";
|
|
14
|
+
export * from "./models/index.js";
|
|
15
|
+
export * from "./auth/index.js";
|
|
16
|
+
export * from "./routes/index.js";
|
|
17
|
+
export * from "./security/index.js";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides a common base class for all entity's that will be persisted to a datastore.
|
|
3
|
+
*
|
|
4
|
+
* Note that the `@CreateDateColumn`, `@UpdateDateColumn`, and `@VersionColumn` decorators from TypeORM are not supported
|
|
5
|
+
* because they are not implemented in TypeORM's MongoDB support. They are instead implemented directly by this
|
|
6
|
+
* library as part of `ModelRoute`.
|
|
7
|
+
*
|
|
8
|
+
* @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class BaseEntity {
|
|
11
|
+
/**
|
|
12
|
+
* The universally unique identifier of the entity.
|
|
13
|
+
*/
|
|
14
|
+
uid: string;
|
|
15
|
+
/**
|
|
16
|
+
* The date and time that the entity was created.
|
|
17
|
+
*/
|
|
18
|
+
dateCreated: Date;
|
|
19
|
+
/**
|
|
20
|
+
* The date and time that the entity was last modified.
|
|
21
|
+
*/
|
|
22
|
+
dateModified: Date;
|
|
23
|
+
/**
|
|
24
|
+
* The optimistic lock version.
|
|
25
|
+
*/
|
|
26
|
+
version: number;
|
|
27
|
+
constructor(other?: Partial<BaseEntity>);
|
|
28
|
+
}
|
|
29
|
+
export type PartialBaseEntity<T extends BaseEntity> = Partial<T> & Pick<T, "uid"> & Pick<T, "version">;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseEntity } from "./BaseEntity.js";
|
|
2
|
+
/**
|
|
3
|
+
* Provides a common base class for all entity's that will be persisted in a MongoDB database.
|
|
4
|
+
*
|
|
5
|
+
* @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class BaseMongoEntity extends BaseEntity {
|
|
8
|
+
/**
|
|
9
|
+
* The internal unique identifier used by MongoDB.
|
|
10
|
+
*/
|
|
11
|
+
_id?: any;
|
|
12
|
+
constructor(other?: Partial<BaseMongoEntity>);
|
|
13
|
+
}
|