@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.
Files changed (332) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +16 -0
  3. package/dist/lib/ApiErrors.js +41 -0
  4. package/dist/lib/ApiErrors.js.map +1 -0
  5. package/dist/lib/BackgroundService.js +16 -0
  6. package/dist/lib/BackgroundService.js.map +1 -0
  7. package/dist/lib/BackgroundServiceManager.js +135 -0
  8. package/dist/lib/BackgroundServiceManager.js.map +1 -0
  9. package/dist/lib/BulkError.js +24 -0
  10. package/dist/lib/BulkError.js.map +1 -0
  11. package/dist/lib/EventListenerManager.js +161 -0
  12. package/dist/lib/EventListenerManager.js.map +1 -0
  13. package/dist/lib/NetUtils.js +103 -0
  14. package/dist/lib/NetUtils.js.map +1 -0
  15. package/dist/lib/NotificationUtils.js +34 -0
  16. package/dist/lib/NotificationUtils.js.map +1 -0
  17. package/dist/lib/ObjectFactory.js +90 -0
  18. package/dist/lib/ObjectFactory.js.map +1 -0
  19. package/dist/lib/OpenApiSpec.js +748 -0
  20. package/dist/lib/OpenApiSpec.js.map +1 -0
  21. package/dist/lib/Server.js +549 -0
  22. package/dist/lib/Server.js.map +1 -0
  23. package/dist/lib/Types.js +2 -0
  24. package/dist/lib/Types.js.map +1 -0
  25. package/dist/lib/auth/AuthMiddleware.js +229 -0
  26. package/dist/lib/auth/AuthMiddleware.js.map +1 -0
  27. package/dist/lib/auth/AuthStrategy.js +2 -0
  28. package/dist/lib/auth/AuthStrategy.js.map +1 -0
  29. package/dist/lib/auth/BasicStrategy.js +106 -0
  30. package/dist/lib/auth/BasicStrategy.js.map +1 -0
  31. package/dist/lib/auth/JWTStrategy.js +161 -0
  32. package/dist/lib/auth/JWTStrategy.js.map +1 -0
  33. package/dist/lib/auth/index.js +5 -0
  34. package/dist/lib/auth/index.js.map +1 -0
  35. package/dist/lib/database/ConnectionKinds.js +14 -0
  36. package/dist/lib/database/ConnectionKinds.js.map +1 -0
  37. package/dist/lib/database/ConnectionManager.js +161 -0
  38. package/dist/lib/database/ConnectionManager.js.map +1 -0
  39. package/dist/lib/database/MongoConnection.js +86 -0
  40. package/dist/lib/database/MongoConnection.js.map +1 -0
  41. package/dist/lib/database/MongoRepository.js +136 -0
  42. package/dist/lib/database/MongoRepository.js.map +1 -0
  43. package/dist/lib/database/MongoSchemaSync.js +136 -0
  44. package/dist/lib/database/MongoSchemaSync.js.map +1 -0
  45. package/dist/lib/database/NamingUtils.js +52 -0
  46. package/dist/lib/database/NamingUtils.js.map +1 -0
  47. package/dist/lib/database/TypeOrmSupport.js +146 -0
  48. package/dist/lib/database/TypeOrmSupport.js.map +1 -0
  49. package/dist/lib/database/index.js +7 -0
  50. package/dist/lib/database/index.js.map +1 -0
  51. package/dist/lib/decorators/DatabaseDecorators.js +52 -0
  52. package/dist/lib/decorators/DatabaseDecorators.js.map +1 -0
  53. package/dist/lib/decorators/DocDecorators.js +120 -0
  54. package/dist/lib/decorators/DocDecorators.js.map +1 -0
  55. package/dist/lib/decorators/EventDecorators.js +24 -0
  56. package/dist/lib/decorators/EventDecorators.js.map +1 -0
  57. package/dist/lib/decorators/ModelDecorators.js +173 -0
  58. package/dist/lib/decorators/ModelDecorators.js.map +1 -0
  59. package/dist/lib/decorators/PersistenceDecorators.js +177 -0
  60. package/dist/lib/decorators/PersistenceDecorators.js.map +1 -0
  61. package/dist/lib/decorators/RouteDecorators.js +324 -0
  62. package/dist/lib/decorators/RouteDecorators.js.map +1 -0
  63. package/dist/lib/decorators/index.js +7 -0
  64. package/dist/lib/decorators/index.js.map +1 -0
  65. package/dist/lib/http/Adapters.js +230 -0
  66. package/dist/lib/http/Adapters.js.map +1 -0
  67. package/dist/lib/http/Router.js +403 -0
  68. package/dist/lib/http/Router.js.map +1 -0
  69. package/dist/lib/http/WebSocket.js +82 -0
  70. package/dist/lib/http/WebSocket.js.map +1 -0
  71. package/dist/lib/http/index.js +4 -0
  72. package/dist/lib/http/index.js.map +1 -0
  73. package/dist/lib/http/types.js +5 -0
  74. package/dist/lib/http/types.js.map +1 -0
  75. package/dist/lib/index.js +18 -0
  76. package/dist/lib/index.js.map +1 -0
  77. package/dist/lib/models/BaseEntity.js +83 -0
  78. package/dist/lib/models/BaseEntity.js.map +1 -0
  79. package/dist/lib/models/BaseMongoEntity.js +40 -0
  80. package/dist/lib/models/BaseMongoEntity.js.map +1 -0
  81. package/dist/lib/models/ModelUtils.js +645 -0
  82. package/dist/lib/models/ModelUtils.js.map +1 -0
  83. package/dist/lib/models/RecoverableBaseEntity.js +39 -0
  84. package/dist/lib/models/RecoverableBaseEntity.js.map +1 -0
  85. package/dist/lib/models/RecoverableBaseMongoEntity.js +40 -0
  86. package/dist/lib/models/RecoverableBaseMongoEntity.js.map +1 -0
  87. package/dist/lib/models/RepoUtils.js +717 -0
  88. package/dist/lib/models/RepoUtils.js.map +1 -0
  89. package/dist/lib/models/SimpleEntity.js +42 -0
  90. package/dist/lib/models/SimpleEntity.js.map +1 -0
  91. package/dist/lib/models/SimpleMongoEntity.js +38 -0
  92. package/dist/lib/models/SimpleMongoEntity.js.map +1 -0
  93. package/dist/lib/models/StatusExtraData.js +15 -0
  94. package/dist/lib/models/StatusExtraData.js.map +1 -0
  95. package/dist/lib/models/index.js +10 -0
  96. package/dist/lib/models/index.js.map +1 -0
  97. package/dist/lib/routes/AdminRoute.js +268 -0
  98. package/dist/lib/routes/AdminRoute.js.map +1 -0
  99. package/dist/lib/routes/MetricsRoute.js +86 -0
  100. package/dist/lib/routes/MetricsRoute.js.map +1 -0
  101. package/dist/lib/routes/ModelRoute.js +481 -0
  102. package/dist/lib/routes/ModelRoute.js.map +1 -0
  103. package/dist/lib/routes/OpenAPIRoute.js +115 -0
  104. package/dist/lib/routes/OpenAPIRoute.js.map +1 -0
  105. package/dist/lib/routes/RouteUtils.js +445 -0
  106. package/dist/lib/routes/RouteUtils.js.map +1 -0
  107. package/dist/lib/routes/StatusRoute.js +55 -0
  108. package/dist/lib/routes/StatusRoute.js.map +1 -0
  109. package/dist/lib/routes/index.js +7 -0
  110. package/dist/lib/routes/index.js.map +1 -0
  111. package/dist/lib/security/ACLRouteMongo.js +194 -0
  112. package/dist/lib/security/ACLRouteMongo.js.map +1 -0
  113. package/dist/lib/security/ACLRouteSQL.js +193 -0
  114. package/dist/lib/security/ACLRouteSQL.js.map +1 -0
  115. package/dist/lib/security/ACLUtils.js +457 -0
  116. package/dist/lib/security/ACLUtils.js.map +1 -0
  117. package/dist/lib/security/AccessControlList.js +18 -0
  118. package/dist/lib/security/AccessControlList.js.map +1 -0
  119. package/dist/lib/security/AccessControlListMongo.js +155 -0
  120. package/dist/lib/security/AccessControlListMongo.js.map +1 -0
  121. package/dist/lib/security/AccessControlListSQL.js +149 -0
  122. package/dist/lib/security/AccessControlListSQL.js.map +1 -0
  123. package/dist/lib/security/index.js +3 -0
  124. package/dist/lib/security/index.js.map +1 -0
  125. package/dist/lib/test/index.js +3 -0
  126. package/dist/lib/test/index.js.map +1 -0
  127. package/dist/lib/test/request.js +99 -0
  128. package/dist/lib/test/request.js.map +1 -0
  129. package/dist/lib/test/requestws.js +173 -0
  130. package/dist/lib/test/requestws.js.map +1 -0
  131. package/dist/types/ApiErrors.d.ts +38 -0
  132. package/dist/types/BackgroundService.d.ts +30 -0
  133. package/dist/types/BackgroundServiceManager.d.ts +66 -0
  134. package/dist/types/BulkError.d.ts +11 -0
  135. package/dist/types/EventListenerManager.d.ts +36 -0
  136. package/dist/types/NetUtils.d.ts +29 -0
  137. package/dist/types/NotificationUtils.d.ts +25 -0
  138. package/dist/types/ObjectFactory.d.ts +17 -0
  139. package/dist/types/OpenApiSpec.d.ts +114 -0
  140. package/dist/types/Server.d.ts +180 -0
  141. package/dist/types/Types.d.ts +8 -0
  142. package/dist/types/auth/AuthMiddleware.d.ts +42 -0
  143. package/dist/types/auth/AuthStrategy.d.ts +32 -0
  144. package/dist/types/auth/BasicStrategy.d.ts +33 -0
  145. package/dist/types/auth/JWTStrategy.d.ts +61 -0
  146. package/dist/types/auth/index.d.ts +4 -0
  147. package/dist/types/database/ConnectionKinds.d.ts +7 -0
  148. package/dist/types/database/ConnectionManager.d.ts +35 -0
  149. package/dist/types/database/MongoConnection.d.ts +54 -0
  150. package/dist/types/database/MongoRepository.d.ts +92 -0
  151. package/dist/types/database/MongoSchemaSync.d.ts +41 -0
  152. package/dist/types/database/NamingUtils.d.ts +24 -0
  153. package/dist/types/database/TypeOrmSupport.d.ts +20 -0
  154. package/dist/types/database/index.d.ts +6 -0
  155. package/dist/types/decorators/DatabaseDecorators.d.ts +18 -0
  156. package/dist/types/decorators/DocDecorators.d.ts +69 -0
  157. package/dist/types/decorators/EventDecorators.d.ts +12 -0
  158. package/dist/types/decorators/ModelDecorators.d.ts +80 -0
  159. package/dist/types/decorators/PersistenceDecorators.d.ts +117 -0
  160. package/dist/types/decorators/RouteDecorators.d.ts +172 -0
  161. package/dist/types/decorators/index.d.ts +6 -0
  162. package/dist/types/http/Adapters.d.ts +68 -0
  163. package/dist/types/http/Router.d.ts +99 -0
  164. package/dist/types/http/WebSocket.d.ts +56 -0
  165. package/dist/types/http/index.d.ts +6 -0
  166. package/dist/types/http/types.d.ts +54 -0
  167. package/dist/types/index.d.ts +17 -0
  168. package/dist/types/models/BaseEntity.d.ts +29 -0
  169. package/dist/types/models/BaseMongoEntity.d.ts +13 -0
  170. package/dist/types/models/ModelUtils.d.ts +166 -0
  171. package/dist/types/models/RecoverableBaseEntity.d.ts +16 -0
  172. package/dist/types/models/RecoverableBaseMongoEntity.d.ts +16 -0
  173. package/dist/types/models/RepoUtils.d.ts +154 -0
  174. package/dist/types/models/SimpleEntity.d.ts +14 -0
  175. package/dist/types/models/SimpleMongoEntity.d.ts +15 -0
  176. package/dist/types/models/StatusExtraData.d.ts +6 -0
  177. package/dist/types/models/index.d.ts +9 -0
  178. package/dist/types/routes/AdminRoute.d.ts +47 -0
  179. package/dist/types/routes/MetricsRoute.d.ts +15 -0
  180. package/dist/types/routes/ModelRoute.d.ts +226 -0
  181. package/dist/types/routes/OpenAPIRoute.d.ts +17 -0
  182. package/dist/types/routes/RouteUtils.d.ts +55 -0
  183. package/dist/types/routes/StatusRoute.d.ts +11 -0
  184. package/dist/types/routes/index.d.ts +6 -0
  185. package/dist/types/security/ACLRouteMongo.d.ts +19 -0
  186. package/dist/types/security/ACLRouteSQL.d.ts +19 -0
  187. package/dist/types/security/ACLUtils.d.ts +94 -0
  188. package/dist/types/security/AccessControlList.d.ts +103 -0
  189. package/dist/types/security/AccessControlListMongo.d.ts +24 -0
  190. package/dist/types/security/AccessControlListSQL.d.ts +24 -0
  191. package/dist/types/security/index.d.ts +2 -0
  192. package/dist/types/test/index.d.ts +2 -0
  193. package/dist/types/test/request.d.ts +24 -0
  194. package/dist/types/test/requestws.d.ts +21 -0
  195. package/docs/Makefile +20 -0
  196. package/docs/conf.py +58 -0
  197. package/docs/index.rst +17 -0
  198. package/docs/make.bat +35 -0
  199. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/README.md +13 -0
  200. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/MongoRepository.md +25 -0
  201. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/RedisConnection.md +25 -0
  202. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/Repository.md +25 -0
  203. package/docs/reference/@rapidrest/namespaces/DocDecorators/README.md +23 -0
  204. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Default.md +25 -0
  205. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Description.md +25 -0
  206. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Document.md +25 -0
  207. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Example.md +25 -0
  208. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Format.md +25 -0
  209. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Returns.md +28 -0
  210. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Summary.md +25 -0
  211. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Tags.md +25 -0
  212. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/TypeInfo.md +28 -0
  213. package/docs/reference/@rapidrest/namespaces/DocDecorators/interfaces/DocumentsData.md +57 -0
  214. package/docs/reference/@rapidrest/namespaces/EventDecorators/README.md +12 -0
  215. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/EventListener.md +17 -0
  216. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/OnEvent.md +26 -0
  217. package/docs/reference/@rapidrest/namespaces/ModelDecorators/README.md +26 -0
  218. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Cache.md +25 -0
  219. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/ChildEntity.md +18 -0
  220. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/DataStore.md +25 -0
  221. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Identifier.md +27 -0
  222. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Protect.md +35 -0
  223. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Reference.md +25 -0
  224. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Shard.md +27 -0
  225. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/TrackChanges.md +26 -0
  226. package/docs/reference/@rapidrest/namespaces/ModelDecorators/interfaces/PendingTypeOrmColumn.md +45 -0
  227. package/docs/reference/@rapidrest/namespaces/ModelDecorators/variables/pendingTypeOrmColumns.md +14 -0
  228. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/README.md +25 -0
  229. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Column.md +25 -0
  230. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Entity.md +26 -0
  231. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Index.md +119 -0
  232. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/PrimaryColumn.md +25 -0
  233. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Unique.md +68 -0
  234. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getColumnMetadata.md +26 -0
  235. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getEntityName.md +26 -0
  236. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getIndexMetadata.md +27 -0
  237. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnInfo.md +41 -0
  238. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnOptions.md +51 -0
  239. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexInfo.md +41 -0
  240. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexOptions.md +51 -0
  241. package/docs/reference/@rapidrest/namespaces/RouteDecorators/README.md +36 -0
  242. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/After.md +26 -0
  243. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Auth.md +33 -0
  244. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/AuthResult.md +31 -0
  245. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Before.md +25 -0
  246. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/ContentType.md +25 -0
  247. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Delete.md +25 -0
  248. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Get.md +25 -0
  249. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Head.md +25 -0
  250. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Header.md +25 -0
  251. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Method.md +31 -0
  252. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Model.md +25 -0
  253. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Options.md +25 -0
  254. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Param.md +26 -0
  255. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Patch.md +25 -0
  256. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Post.md +25 -0
  257. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Protect.md +31 -0
  258. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Put.md +25 -0
  259. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Query.md +26 -0
  260. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Request.md +31 -0
  261. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/RequiresRole.md +26 -0
  262. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Response.md +31 -0
  263. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Route.md +25 -0
  264. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Socket.md +33 -0
  265. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/User.md +31 -0
  266. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Validate.md +25 -0
  267. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/WebSocket.md +25 -0
  268. package/docs/reference/README.md +20 -0
  269. package/docs/reference/classes/ACLUtils.md +251 -0
  270. package/docs/reference/classes/AdminRoute.md +51 -0
  271. package/docs/reference/classes/AuthMiddleware.md +131 -0
  272. package/docs/reference/classes/BackgroundService.md +117 -0
  273. package/docs/reference/classes/BackgroundServiceManager.md +172 -0
  274. package/docs/reference/classes/BaseEntity.md +82 -0
  275. package/docs/reference/classes/BaseMongoEntity.md +107 -0
  276. package/docs/reference/classes/BasicStrategy.md +89 -0
  277. package/docs/reference/classes/BasicStrategyOptions.md +91 -0
  278. package/docs/reference/classes/BulkError.md +271 -0
  279. package/docs/reference/classes/ConnectionManager.md +75 -0
  280. package/docs/reference/classes/EventListenerManager.md +88 -0
  281. package/docs/reference/classes/JWTStrategy.md +77 -0
  282. package/docs/reference/classes/JWTStrategyOptions.md +97 -0
  283. package/docs/reference/classes/MetricsRoute.md +27 -0
  284. package/docs/reference/classes/ModelRoute.md +527 -0
  285. package/docs/reference/classes/ModelUtils.md +448 -0
  286. package/docs/reference/classes/MongoConnection.md +218 -0
  287. package/docs/reference/classes/MongoRepository.md +354 -0
  288. package/docs/reference/classes/MongoSchemaSync.md +67 -0
  289. package/docs/reference/classes/NetUtils.md +90 -0
  290. package/docs/reference/classes/NotificationUtils.md +77 -0
  291. package/docs/reference/classes/ObjectFactory.md +336 -0
  292. package/docs/reference/classes/OpenAPIRoute.md +77 -0
  293. package/docs/reference/classes/OpenApiSpec.md +892 -0
  294. package/docs/reference/classes/RecoverableBaseEntity.md +114 -0
  295. package/docs/reference/classes/RecoverableBaseMongoEntity.md +124 -0
  296. package/docs/reference/classes/RedisTransport.md +2202 -0
  297. package/docs/reference/classes/RepoUtils.md +486 -0
  298. package/docs/reference/classes/RouteUtils.md +191 -0
  299. package/docs/reference/classes/Server.md +408 -0
  300. package/docs/reference/classes/SimpleEntity.md +48 -0
  301. package/docs/reference/classes/SimpleMongoEntity.md +66 -0
  302. package/docs/reference/classes/StatusExtraData.md +57 -0
  303. package/docs/reference/classes/StatusRoute.md +26 -0
  304. package/docs/reference/enumerations/ACLAction.md +63 -0
  305. package/docs/reference/enumerations/ApiErrorMessages.md +123 -0
  306. package/docs/reference/enumerations/ApiErrors.md +123 -0
  307. package/docs/reference/functions/isSqlDataSource.md +26 -0
  308. package/docs/reference/functions/resolveCollectionName.md +33 -0
  309. package/docs/reference/functions/snakeCase.md +28 -0
  310. package/docs/reference/globals.md +91 -0
  311. package/docs/reference/interfaces/ACLRecord.md +96 -0
  312. package/docs/reference/interfaces/AccessControlList.md +76 -0
  313. package/docs/reference/interfaces/AuthResult.md +55 -0
  314. package/docs/reference/interfaces/AuthStrategy.md +57 -0
  315. package/docs/reference/interfaces/CreateRequestOptions.md +121 -0
  316. package/docs/reference/interfaces/DeleteRequestOptions.md +147 -0
  317. package/docs/reference/interfaces/FindRequestOptions.md +133 -0
  318. package/docs/reference/interfaces/JWTAuthResult.md +84 -0
  319. package/docs/reference/interfaces/RepoCreateOptions.md +95 -0
  320. package/docs/reference/interfaces/RepoDeleteOptions.md +115 -0
  321. package/docs/reference/interfaces/RepoFindOptions.md +135 -0
  322. package/docs/reference/interfaces/RepoOperationOptions.md +69 -0
  323. package/docs/reference/interfaces/RepoUpdateOptions.md +111 -0
  324. package/docs/reference/interfaces/RequestOptions.md +112 -0
  325. package/docs/reference/interfaces/TruncateRequestOptions.md +175 -0
  326. package/docs/reference/interfaces/UpdateRequestOptions.md +149 -0
  327. package/docs/reference/type-aliases/OneOrMany.md +19 -0
  328. package/docs/reference/type-aliases/OneOrNull.md +19 -0
  329. package/docs/reference/type-aliases/PartialBaseEntity.md +17 -0
  330. package/docs/reference/type-aliases/PartialSimpleEntity.md +17 -0
  331. package/docs/reference/type-aliases/UpdateObject.md +19 -0
  332. package/package.json +125 -0
@@ -0,0 +1,230 @@
1
+ /** Parses a `cookie` header string into a key/value map. */
2
+ function parseCookies(cookieHeader) {
3
+ const result = {};
4
+ if (!cookieHeader)
5
+ return result;
6
+ for (const part of cookieHeader.split(";")) {
7
+ const idx = part.indexOf("=");
8
+ if (idx < 0)
9
+ continue;
10
+ const key = part.slice(0, idx).trim();
11
+ const val = part.slice(idx + 1).trim();
12
+ result[key] = decodeURIComponent(val);
13
+ }
14
+ return result;
15
+ }
16
+ /** Parses a URL query string (without leading `?`) into a key/value map. */
17
+ function parseQueryString(qs) {
18
+ const result = {};
19
+ if (!qs)
20
+ return result;
21
+ for (const part of qs.split("&")) {
22
+ const idx = part.indexOf("=");
23
+ if (idx < 0) {
24
+ let key;
25
+ try {
26
+ key = decodeURIComponent(part);
27
+ }
28
+ catch {
29
+ key = part;
30
+ }
31
+ result[key] = "";
32
+ continue;
33
+ }
34
+ let key;
35
+ let val;
36
+ try {
37
+ key = decodeURIComponent(part.slice(0, idx));
38
+ val = decodeURIComponent(part.slice(idx + 1));
39
+ }
40
+ catch {
41
+ key = part.slice(0, idx);
42
+ val = part.slice(idx + 1);
43
+ }
44
+ if (key in result) {
45
+ const existing = result[key];
46
+ result[key] = Array.isArray(existing) ? [...existing, val] : [existing, val];
47
+ }
48
+ else {
49
+ result[key] = val;
50
+ }
51
+ }
52
+ return result;
53
+ }
54
+ /**
55
+ * Adapts a uWS `HttpRequest` to the framework-agnostic `HttpRequest` interface.
56
+ *
57
+ * IMPORTANT: uWS HttpRequest is stack-allocated and only valid during the synchronous portion of
58
+ * the handler. All request data MUST be captured in the constructor before any `await`.
59
+ */
60
+ export class UWSRequest {
61
+ constructor(uwsReq, remoteAddress) {
62
+ this.params = {};
63
+ this.body = undefined;
64
+ this.signedCookies = {};
65
+ // Capture all uWS request data synchronously — req becomes invalid after first await
66
+ this.method = uwsReq.getMethod().toUpperCase();
67
+ const rawUrl = uwsReq.getUrl();
68
+ this.url = rawUrl;
69
+ this.path = rawUrl;
70
+ // Capture all headers
71
+ const headers = {};
72
+ uwsReq.forEach((key, value) => {
73
+ headers[key.toLowerCase()] = value;
74
+ });
75
+ this.headers = headers;
76
+ // Parse cookies from the cookie header
77
+ this.cookies = parseCookies(headers["cookie"] || "");
78
+ // Parse query string
79
+ this.query = parseQueryString(uwsReq.getQuery());
80
+ // Remote address for IP utilities
81
+ this.socket = { remoteAddress };
82
+ }
83
+ }
84
+ /**
85
+ * Adapts a uWS `HttpResponse` to the framework-agnostic `HttpResponse` interface.
86
+ *
87
+ * Buffers headers and status code until the first write. Tracks abort state to safely
88
+ * skip writes on aborted connections. All uWS writes are wrapped in `res.cork()` for
89
+ * optimal performance.
90
+ */
91
+ export class UWSResponse {
92
+ constructor(uwsRes) {
93
+ this._statusCode = 200;
94
+ this._headers = new Map();
95
+ this._headersSent = false;
96
+ this._writableEnded = false;
97
+ this._aborted = false;
98
+ /** Set to true for HEAD requests — body bytes must not be sent. */
99
+ this.isHead = false;
100
+ this.uwsRes = uwsRes;
101
+ // Track connection abort so we don't attempt writes on a closed socket
102
+ uwsRes.onAborted(() => {
103
+ this._aborted = true;
104
+ });
105
+ }
106
+ get statusCode() {
107
+ return this._statusCode;
108
+ }
109
+ get headersSent() {
110
+ return this._headersSent;
111
+ }
112
+ get writableEnded() {
113
+ return this._writableEnded;
114
+ }
115
+ status(code) {
116
+ this._statusCode = code;
117
+ return this;
118
+ }
119
+ setHeader(key, value) {
120
+ this._headers.set(key.toLowerCase(), String(value));
121
+ return this;
122
+ }
123
+ getHeader(key) {
124
+ return this._headers.get(key.toLowerCase());
125
+ }
126
+ json(data) {
127
+ this._headers.set("content-type", "application/json");
128
+ this.end(JSON.stringify(data));
129
+ }
130
+ send(data) {
131
+ if (data === undefined || data === null) {
132
+ this.end();
133
+ }
134
+ else if (typeof data === "object" && !Buffer.isBuffer(data)) {
135
+ this.json(data);
136
+ }
137
+ else {
138
+ this.end(data);
139
+ }
140
+ }
141
+ end(data) {
142
+ if (this._aborted || this._writableEnded)
143
+ return;
144
+ this._writableEnded = true;
145
+ this.uwsRes.cork(() => {
146
+ // Write status line (uWS expects "200 OK" format)
147
+ if (!this._headersSent) {
148
+ this.uwsRes.writeStatus(this._statusToString(this._statusCode));
149
+ // Write all buffered headers except content-length:
150
+ // uWS auto-adds content-length via end(data) or endWithoutBody(n), so
151
+ // writing it manually would create a duplicate Content-Length header.
152
+ for (const [key, value] of this._headers.entries()) {
153
+ if (key === "content-length")
154
+ continue;
155
+ this.uwsRes.writeHeader(key, value);
156
+ }
157
+ this._headersSent = true;
158
+ }
159
+ if (this.isHead) {
160
+ // HEAD: use endWithoutBody so uWS sets Content-Length from the reported size
161
+ // without sending body bytes. Allows doCount/doExists to report a count via
162
+ // content-length without triggering the duplicate-header bug.
163
+ const cl = this._headers.get("content-length");
164
+ this.uwsRes.endWithoutBody(cl !== undefined ? parseInt(cl, 10) : undefined);
165
+ }
166
+ else if (data === undefined || data === null) {
167
+ this.uwsRes.end();
168
+ }
169
+ else {
170
+ this.uwsRes.end(data);
171
+ }
172
+ });
173
+ }
174
+ /** Converts a numeric status code to the "200 OK" string format uWS expects. */
175
+ _statusToString(code) {
176
+ const messages = {
177
+ 100: "Continue", 101: "Switching Protocols",
178
+ 200: "OK", 201: "Created", 202: "Accepted", 204: "No Content", 206: "Partial Content",
179
+ 301: "Moved Permanently", 302: "Found", 304: "Not Modified",
180
+ 400: "Bad Request", 401: "Unauthorized", 403: "Forbidden", 404: "Not Found",
181
+ 405: "Method Not Allowed", 409: "Conflict", 410: "Gone", 422: "Unprocessable Entity",
182
+ 429: "Too Many Requests",
183
+ 500: "Internal Server Error", 501: "Not Implemented", 502: "Bad Gateway", 503: "Service Unavailable",
184
+ };
185
+ return `${code} ${messages[code] || "Unknown"}`;
186
+ }
187
+ }
188
+ /**
189
+ * Reads the full request body from a uWS response object as a Buffer.
190
+ * Body parsing (JSON / URL-encoded) is applied based on content-type and the result
191
+ * is cached on `req.body` / `req.rawBody`.
192
+ */
193
+ export function readBody(uwsRes, req) {
194
+ return new Promise((resolve, reject) => {
195
+ if (req.body !== undefined) {
196
+ resolve();
197
+ return;
198
+ }
199
+ const chunks = [];
200
+ uwsRes.onData((chunk, isLast) => {
201
+ chunks.push(Buffer.from(chunk));
202
+ if (isLast) {
203
+ const raw = Buffer.concat(chunks);
204
+ req.rawBody = raw;
205
+ if (raw.length > 0) {
206
+ const contentType = String(req.headers["content-type"] || "").toLowerCase();
207
+ if (contentType.includes("application/json")) {
208
+ try {
209
+ req.body = JSON.parse(raw.toString("utf8"));
210
+ }
211
+ catch {
212
+ req.body = raw.toString("utf8");
213
+ }
214
+ }
215
+ else if (contentType.includes("application/x-www-form-urlencoded")) {
216
+ req.body = Object.fromEntries(new URLSearchParams(raw.toString("utf8")).entries());
217
+ }
218
+ else {
219
+ req.body = raw;
220
+ }
221
+ }
222
+ else {
223
+ req.body = undefined;
224
+ }
225
+ resolve();
226
+ }
227
+ });
228
+ });
229
+ }
230
+ //# sourceMappingURL=Adapters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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AAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;oBACpF,IAAI,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;wBAC3C,IAAI,CAAC;4BACD,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;wBAChD,CAAC;wBAAC,MAAM,CAAC;4BACL,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;wBACpC,CAAC;oBACL,CAAC;yBAAM,IAAI,WAAW,CAAC,QAAQ,CAAC,mCAAmC,CAAC,EAAE,CAAC;wBACnE,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC,WAAW,CACzB,IAAI,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CACtD,CAAC;oBACN,CAAC;yBAAM,CAAC;wBACJ,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC;oBACnB,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACJ,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC;gBACzB,CAAC;gBAED,OAAO,EAAE,CAAC;YACd,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,403 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2020-2026 Jean-Philippe Steinmetz. All rights reserved.
3
+ ///////////////////////////////////////////////////////////////////////////////
4
+ import uWS from "uWebSockets.js";
5
+ import * as fs from "fs";
6
+ import * as path from "path";
7
+ import { UWSRequest, UWSResponse, readBody } from "./Adapters.js";
8
+ import { UWSWebSocketShim } from "./WebSocket.js";
9
+ /** MIME types for static file serving. */
10
+ const MIME_TYPES = {
11
+ ".html": "text/html",
12
+ ".css": "text/css",
13
+ ".js": "application/javascript",
14
+ ".mjs": "application/javascript",
15
+ ".json": "application/json",
16
+ ".png": "image/png",
17
+ ".jpg": "image/jpeg",
18
+ ".jpeg": "image/jpeg",
19
+ ".gif": "image/gif",
20
+ ".svg": "image/svg+xml",
21
+ ".ico": "image/x-icon",
22
+ ".woff": "font/woff",
23
+ ".woff2": "font/woff2",
24
+ ".ttf": "font/ttf",
25
+ ".txt": "text/plain",
26
+ ".map": "application/json",
27
+ };
28
+ /**
29
+ * Runs an ordered array of middleware handlers sequentially, Express-style.
30
+ * Supports both 3-param `(req, res, next)` handlers and 4-param `(err, req, res, next)`
31
+ * error handlers. On error, execution skips to the next error handler.
32
+ *
33
+ * Each handler is awaited via a Promise that resolves when next() is called, not when
34
+ * the handler's return value resolves. This correctly handles: (1) sync handlers that
35
+ * call next() synchronously, (2) async handlers that return next() or await before
36
+ * calling it, and (3) sync handlers that schedule next() via callbacks such as
37
+ * setTimeout or socket.once. The chain terminates early when a handler ends the
38
+ * response without calling next().
39
+ */
40
+ export async function runChain(handlers, req, res) {
41
+ let currentError = undefined;
42
+ for (let i = 0; i < handlers.length; i++) {
43
+ const handler = handlers[i];
44
+ const isErrorHandler = handler.length === 4;
45
+ if (currentError && !isErrorHandler)
46
+ continue;
47
+ if (!currentError && isErrorHandler)
48
+ continue;
49
+ const outcome = await new Promise((resolve) => {
50
+ let settled = false;
51
+ const next = (err) => {
52
+ if (!settled) {
53
+ settled = true;
54
+ resolve({ called: true, err });
55
+ }
56
+ };
57
+ try {
58
+ const handlerResult = isErrorHandler
59
+ ? handler(currentError, req, res, next)
60
+ : handler(req, res, next);
61
+ if (handlerResult instanceof Promise) {
62
+ // Async handler: wait for the Promise, but next() may have already been
63
+ // called (or may be called later inside the Promise chain).
64
+ handlerResult
65
+ .then(() => {
66
+ if (!settled) {
67
+ settled = true;
68
+ resolve({ called: false });
69
+ }
70
+ })
71
+ .catch((err) => {
72
+ if (!settled) {
73
+ settled = true;
74
+ resolve({ called: true, err });
75
+ }
76
+ });
77
+ }
78
+ else {
79
+ // Sync handler returned. Three sub-cases:
80
+ // a. next() was already called synchronously → already settled.
81
+ // b. Response was sent without next() → stop chain.
82
+ // c. Handler will call next() from an async callback (e.g. setTimeout)
83
+ // → leave the Promise pending; it resolves when next() fires.
84
+ if (!settled && res.writableEnded) {
85
+ settled = true;
86
+ resolve({ called: false });
87
+ }
88
+ // else: wait for next() to be called asynchronously
89
+ }
90
+ }
91
+ catch (err) {
92
+ if (!settled) {
93
+ settled = true;
94
+ resolve({ called: true, err });
95
+ }
96
+ }
97
+ });
98
+ if (!outcome.called)
99
+ break; // handler terminated chain (sent response)
100
+ if (outcome.err !== undefined) {
101
+ currentError = outcome.err;
102
+ }
103
+ else if (isErrorHandler) {
104
+ currentError = undefined; // error was handled
105
+ }
106
+ }
107
+ // End of chain with unhandled error
108
+ if (currentError && !res.writableEnded) {
109
+ res.status(500).json({
110
+ message: currentError?.message || "Internal Server Error",
111
+ status: 500,
112
+ });
113
+ }
114
+ }
115
+ /** Parses `:param` names out of a uWS route pattern (e.g. `/users/:uid/:version` → `["uid","version"]`). */
116
+ function extractParamNames(routePath) {
117
+ const names = [];
118
+ for (const segment of routePath.split("/")) {
119
+ if (segment.startsWith(":"))
120
+ names.push(segment.slice(1));
121
+ }
122
+ return names;
123
+ }
124
+ /**
125
+ * Wraps a uWS route handler to convert uWS request/response objects into `HttpRequest`/`HttpResponse`
126
+ * adapters, reads the body, and runs the full middleware chain (pre-route global + route-specific + post-route global).
127
+ *
128
+ * `preLength` is the number of global middleware items that were registered BEFORE this route was registered.
129
+ * At invocation time we split `globalMiddleware` at that index so that error handlers and metrics registered
130
+ * AFTER the routes are placed after the route handlers in the chain (matching Express middleware ordering).
131
+ */
132
+ function makeUWSHandler(globalMiddleware, routeHandlers, preLength, paramNames, isHead = false) {
133
+ return async (uwsRes, uwsReq) => {
134
+ // Capture remote address before any async work
135
+ const remoteAddress = Buffer.from(uwsRes.getRemoteAddressAsText()).toString();
136
+ // Build adapters — all uWS HttpRequest reads happen here synchronously
137
+ const req = new UWSRequest(uwsReq, remoteAddress);
138
+ const res = new UWSResponse(uwsRes);
139
+ res.isHead = isHead;
140
+ // Capture path params synchronously (uwsReq is stack-allocated, only valid before first await)
141
+ for (let i = 0; i < paramNames.length; i++) {
142
+ req.params[paramNames[i]] = uwsReq.getParameter(i) || "";
143
+ }
144
+ // Body must be read before any middleware runs
145
+ try {
146
+ await readBody(uwsRes, req);
147
+ }
148
+ catch {
149
+ // Non-fatal: body may not exist for GET/HEAD/OPTIONS
150
+ }
151
+ // Split global middleware: pre-route (registered before this route) and post-route (registered after)
152
+ const preMiddleware = globalMiddleware.slice(0, preLength);
153
+ const postMiddleware = globalMiddleware.slice(preLength);
154
+ const allHandlers = [...preMiddleware, ...routeHandlers, ...postMiddleware];
155
+ await runChain(allHandlers, req, res);
156
+ // If no handler sent a response, end with 204
157
+ if (!res.writableEnded && !res["_aborted"]) {
158
+ res.status(204).end();
159
+ }
160
+ };
161
+ }
162
+ /**
163
+ * Thin Express-compatible wrapper over `uWS.TemplatedApp`.
164
+ *
165
+ * Provides the same `app.get()`, `app.post()`, `app.use()`, etc. API that
166
+ * `RouteUtils.registerRoute()` uses, so no changes are needed in route registration
167
+ * code. Global middleware registered via `use()` is prepended to every route's chain.
168
+ *
169
+ * Also supports:
170
+ * - `ws(path, handlers)` — native uWS WebSocket routing
171
+ * - `static(basePath)` — basic static file serving
172
+ * - `listen(host, port)` / `close()` — server lifecycle
173
+ */
174
+ export class HttpRouter {
175
+ constructor(uwsApp) {
176
+ this.globalMiddleware = [];
177
+ this.listenSocket = null;
178
+ /**
179
+ * Number of global middleware items registered BEFORE the first route was added.
180
+ * -1 means no routes have been registered yet (preRouteCount not yet frozen).
181
+ */
182
+ this.preRouteCount = -1;
183
+ /** The port the server is currently listening on (set after a successful `listen()` call). */
184
+ this.listenPort = 0;
185
+ this.uwsApp = uwsApp;
186
+ }
187
+ /** Returns `true` if the server is currently listening. */
188
+ get isListening() {
189
+ return this.listenSocket !== null;
190
+ }
191
+ /** Register global middleware that runs before every route handler. */
192
+ use(...handlers) {
193
+ this.globalMiddleware.push(...handlers);
194
+ return this;
195
+ }
196
+ /**
197
+ * Freezes the pre-route middleware count the first time a route is registered.
198
+ * All global middleware registered BEFORE this call is "pre-route" middleware;
199
+ * everything added after is "post-route" (error handlers, metrics, etc.).
200
+ */
201
+ capturePreRouteCount() {
202
+ if (this.preRouteCount === -1) {
203
+ this.preRouteCount = this.globalMiddleware.length;
204
+ }
205
+ return this.preRouteCount;
206
+ }
207
+ // -------------------------------------------------------------------------
208
+ // HTTP verb methods — each registers a uWS route
209
+ // -------------------------------------------------------------------------
210
+ get(routePath, ...handlers) {
211
+ const pre = this.capturePreRouteCount();
212
+ this.uwsApp.get(routePath, makeUWSHandler(this.globalMiddleware, handlers, pre, extractParamNames(routePath)));
213
+ return this;
214
+ }
215
+ post(routePath, ...handlers) {
216
+ const pre = this.capturePreRouteCount();
217
+ this.uwsApp.post(routePath, makeUWSHandler(this.globalMiddleware, handlers, pre, extractParamNames(routePath)));
218
+ return this;
219
+ }
220
+ put(routePath, ...handlers) {
221
+ const pre = this.capturePreRouteCount();
222
+ this.uwsApp.put(routePath, makeUWSHandler(this.globalMiddleware, handlers, pre, extractParamNames(routePath)));
223
+ return this;
224
+ }
225
+ delete(routePath, ...handlers) {
226
+ const pre = this.capturePreRouteCount();
227
+ this.uwsApp.del(routePath, makeUWSHandler(this.globalMiddleware, handlers, pre, extractParamNames(routePath)));
228
+ return this;
229
+ }
230
+ patch(routePath, ...handlers) {
231
+ const pre = this.capturePreRouteCount();
232
+ this.uwsApp.patch(routePath, makeUWSHandler(this.globalMiddleware, handlers, pre, extractParamNames(routePath)));
233
+ return this;
234
+ }
235
+ head(routePath, ...handlers) {
236
+ const pre = this.capturePreRouteCount();
237
+ // uWS explicitly-registered HEAD routes do send body bytes — suppress them via isHead flag
238
+ this.uwsApp.head(routePath, makeUWSHandler(this.globalMiddleware, handlers, pre, extractParamNames(routePath), true));
239
+ return this;
240
+ }
241
+ options(routePath, ...handlers) {
242
+ const pre = this.capturePreRouteCount();
243
+ this.uwsApp.options(routePath, makeUWSHandler(this.globalMiddleware, handlers, pre, extractParamNames(routePath)));
244
+ return this;
245
+ }
246
+ /**
247
+ * Registers a WebSocket route. Handlers follow the same `(req, res, next)` pattern
248
+ * as HTTP routes; they receive `req.websocket` containing the uWS WebSocket handle.
249
+ *
250
+ * `upgradeAuth` is an optional pre-upgrade auth function. When provided it runs synchronously
251
+ * inside the uWS `upgrade` callback before the handshake. If it returns `{ reject: true }`,
252
+ * an HTTP 401 is sent and the upgrade is aborted. If it returns `{ user, ... }`, those
253
+ * credentials are attached to the request so downstream middleware sees an authenticated user.
254
+ * If it returns `{}`, auth falls through to the post-upgrade message-based LOGIN flow.
255
+ *
256
+ * Both `path` and `path + "/"` are registered to avoid trailing-slash mismatch.
257
+ */
258
+ ws(routePath, handlers, wsOptions, upgradeAuth) {
259
+ const behavior = {
260
+ ...wsOptions,
261
+ upgrade: (uwsRes, uwsReq, context) => {
262
+ // Capture all request data synchronously — uWS HttpRequest is stack-allocated
263
+ const remoteAddress = Buffer.from(uwsRes.getRemoteAddressAsText()).toString();
264
+ const req = new UWSRequest(uwsReq, remoteAddress);
265
+ const secWebSocketKey = uwsReq.getHeader("sec-websocket-key");
266
+ const secWebSocketProtocol = uwsReq.getHeader("sec-websocket-protocol");
267
+ const secWebSocketExtensions = uwsReq.getHeader("sec-websocket-extensions");
268
+ if (upgradeAuth) {
269
+ const authResult = upgradeAuth(req);
270
+ if (authResult.reject) {
271
+ // Reject before the WebSocket handshake with HTTP 401
272
+ uwsRes.cork(() => {
273
+ uwsRes.writeStatus("401 Unauthorized");
274
+ uwsRes.writeHeader("content-type", "application/json");
275
+ uwsRes.end(JSON.stringify({ status: 401, message: "Unauthorized" }));
276
+ });
277
+ return;
278
+ }
279
+ // Pre-authenticated — attach credentials so authWebSocket skips LOGIN.
280
+ // Also set req.auth so the @User decorator in wrapMiddleware resolves correctly.
281
+ if (authResult.user) {
282
+ req.user = authResult.user;
283
+ req.auth = authResult;
284
+ req.authPayload = authResult.authPayload;
285
+ req.authToken = authResult.authToken;
286
+ }
287
+ }
288
+ uwsRes.upgrade({ req }, secWebSocketKey, secWebSocketProtocol, secWebSocketExtensions, context);
289
+ },
290
+ open: async (ws) => {
291
+ // Retrieve the request captured during upgrade and attach the shim
292
+ const userData = ws.getUserData();
293
+ const shim = new UWSWebSocketShim(ws);
294
+ userData.shim = shim;
295
+ const req = userData.req;
296
+ req.websocket = shim;
297
+ req.wsHandled = false;
298
+ // Create a stub response (WebSocket responses don't use HTTP res)
299
+ const stubRes = {
300
+ statusCode: 101,
301
+ headersSent: true,
302
+ writableEnded: false,
303
+ status() { return this; },
304
+ setHeader() { return this; },
305
+ getHeader() { return undefined; },
306
+ json() { return; },
307
+ send() { return; },
308
+ end() { this.writableEnded = true; },
309
+ };
310
+ await runChain(handlers, req, stubRes);
311
+ // If no handler marked wsHandled, close the connection.
312
+ // Guard against the client disconnecting while runChain was awaiting
313
+ // (e.g. authWebSocket waiting for a LOGIN frame): the uWS handle is
314
+ // invalid once the close callback fires, so calling ws.close() would
315
+ // throw "Invalid access of closed uWS.WebSocket" as an unhandled
316
+ // rejection from this async open handler.
317
+ if (!req.wsHandled && shim.readyState !== 3) {
318
+ try {
319
+ ws.close();
320
+ }
321
+ catch {
322
+ // Client already disconnected — nothing to do
323
+ }
324
+ }
325
+ },
326
+ message: (ws, message, isBinary) => {
327
+ const userData = ws.getUserData();
328
+ // Forward message events to the per-socket EventEmitter shim
329
+ userData.shim?.emit("message", isBinary ? Buffer.from(message) : Buffer.from(message).toString(), isBinary);
330
+ },
331
+ close: (ws, code, message) => {
332
+ const userData = ws.getUserData();
333
+ userData.shim?.readyState !== undefined && (userData.shim.readyState = 3); // CLOSED
334
+ userData.shim?.emit("close", code, Buffer.from(message).toString());
335
+ },
336
+ };
337
+ this.uwsApp.ws(routePath, behavior);
338
+ // Also register with trailing slash to match Express behavior
339
+ if (!routePath.endsWith("/")) {
340
+ this.uwsApp.ws(routePath + "/", behavior);
341
+ }
342
+ return this;
343
+ }
344
+ /**
345
+ * Serves static files from a directory via a wildcard GET route.
346
+ * Files not found on disk return 404.
347
+ */
348
+ static(basePath) {
349
+ this.uwsApp.get("/*", async (uwsRes, uwsReq) => {
350
+ const remoteAddress = Buffer.from(uwsRes.getRemoteAddressAsText()).toString();
351
+ const req = new UWSRequest(uwsReq, remoteAddress);
352
+ const res = new UWSResponse(uwsRes);
353
+ const safeBase = path.resolve(basePath);
354
+ const requestedPath = req.path === "/" ? "index.html" : req.path.replace(/^\/+/, "");
355
+ const filePath = path.resolve(safeBase, requestedPath);
356
+ if (!filePath.startsWith(safeBase + path.sep) && filePath !== safeBase) {
357
+ res.status(403).end();
358
+ return;
359
+ }
360
+ const ext = path.extname(filePath);
361
+ try {
362
+ const data = await fs.promises.readFile(filePath);
363
+ res.setHeader("content-type", MIME_TYPES[ext] || "application/octet-stream");
364
+ res.end(data);
365
+ }
366
+ catch {
367
+ res.status(404).end();
368
+ }
369
+ });
370
+ return this;
371
+ }
372
+ /**
373
+ * Starts listening on the given host and port.
374
+ * Resolves when the server is ready; rejects if the port cannot be bound.
375
+ */
376
+ listen(host, port) {
377
+ // Register a catch-all OPTIONS handler so CORS global middleware runs for all preflight requests.
378
+ // This must happen before the uWS listen call so it is ready when the first request arrives.
379
+ // preLength=0 places all globalMiddleware as "post-route" so they all execute sequentially;
380
+ // the CORS middleware terminates the chain early for OPTIONS (sends 204 without calling next).
381
+ this.uwsApp.options("/*", makeUWSHandler(this.globalMiddleware, [], 0, []));
382
+ return new Promise((resolve, reject) => {
383
+ this.uwsApp.listen(host, port, (socket) => {
384
+ if (socket) {
385
+ this.listenSocket = socket;
386
+ this.listenPort = port;
387
+ resolve();
388
+ }
389
+ else {
390
+ reject(new Error(`Failed to listen on ${host}:${port}`));
391
+ }
392
+ });
393
+ });
394
+ }
395
+ /** Closes the listen socket, stopping the server from accepting new connections. */
396
+ close() {
397
+ if (this.listenSocket) {
398
+ uWS.us_listen_socket_close(this.listenSocket);
399
+ this.listenSocket = null;
400
+ }
401
+ }
402
+ }
403
+ //# sourceMappingURL=Router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../src/http/Router.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wEAAwE;AACxE,+EAA+E;AAC/E,OAAO,GAAG,MAAM,gBAAgB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAkB,MAAM,gBAAgB,CAAC;AAElE,0CAA0C;AAC1C,MAAM,UAAU,GAA2B;IACvC,OAAO,EAAE,WAAW;IACpB,MAAM,EAAE,UAAU;IAClB,KAAK,EAAE,wBAAwB;IAC/B,MAAM,EAAE,wBAAwB;IAChC,OAAO,EAAE,kBAAkB;IAC3B,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,cAAc;IACtB,OAAO,EAAE,WAAW;IACpB,QAAQ,EAAE,YAAY;IACtB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,kBAAkB;CAC7B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC1B,QAA0B,EAC1B,GAAgB,EAChB,GAAiB;IAEjB,IAAI,YAAY,GAAQ,SAAS,CAAC;IAElC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QA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