@rapidrest/service-core 1.0.0-rc.7 → 1.0.0

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 (380) hide show
  1. package/LICENSE +382 -23
  2. package/README.md +79 -5
  3. package/dist/lib/ApiErrors.js +10 -0
  4. package/dist/lib/ApiErrors.js.map +1 -1
  5. package/dist/lib/BackgroundService.js +1 -4
  6. package/dist/lib/BackgroundService.js.map +1 -1
  7. package/dist/lib/BackgroundServiceManager.js +47 -6
  8. package/dist/lib/BackgroundServiceManager.js.map +1 -1
  9. package/dist/lib/BulkError.js +4 -0
  10. package/dist/lib/BulkError.js.map +1 -1
  11. package/dist/lib/EventListenerManager.js +53 -18
  12. package/dist/lib/EventListenerManager.js.map +1 -1
  13. package/dist/lib/NetUtils.js +1 -0
  14. package/dist/lib/NetUtils.js.map +1 -1
  15. package/dist/lib/NotificationUtils.js +27 -8
  16. package/dist/lib/NotificationUtils.js.map +1 -1
  17. package/dist/lib/ObjectFactory.js +25 -44
  18. package/dist/lib/ObjectFactory.js.map +1 -1
  19. package/dist/lib/OpenApiSpec.js +31 -11
  20. package/dist/lib/OpenApiSpec.js.map +1 -1
  21. package/dist/lib/Server.js +74 -110
  22. package/dist/lib/Server.js.map +1 -1
  23. package/dist/lib/auth/AuthMiddleware.js +11 -16
  24. package/dist/lib/auth/AuthMiddleware.js.map +1 -1
  25. package/dist/lib/auth/JWTStrategy.js +68 -17
  26. package/dist/lib/auth/JWTStrategy.js.map +1 -1
  27. package/dist/lib/auth/index.js +0 -1
  28. package/dist/lib/auth/index.js.map +1 -1
  29. package/dist/lib/database/ConnectionKinds.js +15 -0
  30. package/dist/lib/database/ConnectionKinds.js.map +1 -1
  31. package/dist/lib/database/ConnectionManager.js +140 -61
  32. package/dist/lib/database/ConnectionManager.js.map +1 -1
  33. package/dist/lib/database/MongoConnection.js +13 -3
  34. package/dist/lib/database/MongoConnection.js.map +1 -1
  35. package/dist/lib/database/MongoRepository.js +61 -15
  36. package/dist/lib/database/MongoRepository.js.map +1 -1
  37. package/dist/lib/database/MongoSchemaSync.js +3 -3
  38. package/dist/lib/database/MongoSchemaSync.js.map +1 -1
  39. package/dist/lib/database/NamingUtils.js +3 -2
  40. package/dist/lib/database/NamingUtils.js.map +1 -1
  41. package/dist/lib/database/RedisCache.js +64 -0
  42. package/dist/lib/database/RedisCache.js.map +1 -0
  43. package/dist/lib/database/TypeOrmSupport.js +53 -13
  44. package/dist/lib/database/TypeOrmSupport.js.map +1 -1
  45. package/dist/lib/database/index.js +1 -0
  46. package/dist/lib/database/index.js.map +1 -1
  47. package/dist/lib/decorators/DatabaseDecorators.js +264 -20
  48. package/dist/lib/decorators/DatabaseDecorators.js.map +1 -1
  49. package/dist/lib/decorators/DocDecorators.js +30 -9
  50. package/dist/lib/decorators/DocDecorators.js.map +1 -1
  51. package/dist/lib/decorators/EventDecorators.js +1 -0
  52. package/dist/lib/decorators/EventDecorators.js.map +1 -1
  53. package/dist/lib/decorators/ModelDecorators.js +39 -23
  54. package/dist/lib/decorators/ModelDecorators.js.map +1 -1
  55. package/dist/lib/decorators/PersistenceDecorators.js +4 -3
  56. package/dist/lib/decorators/PersistenceDecorators.js.map +1 -1
  57. package/dist/lib/decorators/RouteDecorators.js +139 -36
  58. package/dist/lib/decorators/RouteDecorators.js.map +1 -1
  59. package/dist/lib/http/IWebSocketShim.js +2 -0
  60. package/dist/lib/http/IWebSocketShim.js.map +1 -0
  61. package/dist/lib/http/MiddlewareChain.js +167 -0
  62. package/dist/lib/http/MiddlewareChain.js.map +1 -0
  63. package/dist/lib/http/RuntimeDetect.js +9 -0
  64. package/dist/lib/http/RuntimeDetect.js.map +1 -0
  65. package/dist/lib/http/bun/BunAdapters.js +326 -0
  66. package/dist/lib/http/bun/BunAdapters.js.map +1 -0
  67. package/dist/lib/http/bun/BunRouter.js +391 -0
  68. package/dist/lib/http/bun/BunRouter.js.map +1 -0
  69. package/dist/lib/http/bun/BunWebSocket.js +49 -0
  70. package/dist/lib/http/bun/BunWebSocket.js.map +1 -0
  71. package/dist/lib/http/index.js +16 -3
  72. package/dist/lib/http/index.js.map +1 -1
  73. package/dist/lib/http/session/RedisSessionStore.js +30 -0
  74. package/dist/lib/http/session/RedisSessionStore.js.map +1 -0
  75. package/dist/lib/http/session/SessionManager.js +113 -0
  76. package/dist/lib/http/session/SessionManager.js.map +1 -0
  77. package/dist/lib/http/session/SessionStore.js +6 -0
  78. package/dist/lib/http/session/SessionStore.js.map +1 -0
  79. package/dist/lib/http/session/sessionMiddleware.js +42 -0
  80. package/dist/lib/http/session/sessionMiddleware.js.map +1 -0
  81. package/dist/lib/http/types.js +0 -3
  82. package/dist/lib/http/types.js.map +1 -1
  83. package/dist/lib/http/uWS/Adapters.js +421 -0
  84. package/dist/lib/http/uWS/Adapters.js.map +1 -0
  85. package/dist/lib/http/{Router.js → uWS/Router.js} +73 -173
  86. package/dist/lib/http/uWS/Router.js.map +1 -0
  87. package/dist/lib/http/{WebSocket.js → uWS/WebSocket.js} +4 -1
  88. package/dist/lib/http/uWS/WebSocket.js.map +1 -0
  89. package/dist/lib/models/BaseEntity.js +2 -1
  90. package/dist/lib/models/BaseEntity.js.map +1 -1
  91. package/dist/lib/models/BaseMongoEntity.js +2 -2
  92. package/dist/lib/models/BaseMongoEntity.js.map +1 -1
  93. package/dist/lib/models/ModelUtils.js +248 -101
  94. package/dist/lib/models/ModelUtils.js.map +1 -1
  95. package/dist/lib/models/RecoverableBaseEntity.js +6 -1
  96. package/dist/lib/models/RecoverableBaseEntity.js.map +1 -1
  97. package/dist/lib/models/RecoverableBaseMongoEntity.js +1 -0
  98. package/dist/lib/models/RecoverableBaseMongoEntity.js.map +1 -1
  99. package/dist/lib/models/RepoUtils.js +641 -203
  100. package/dist/lib/models/RepoUtils.js.map +1 -1
  101. package/dist/lib/models/SimpleEntity.js +1 -0
  102. package/dist/lib/models/SimpleEntity.js.map +1 -1
  103. package/dist/lib/models/SimpleMongoEntity.js +2 -1
  104. package/dist/lib/models/SimpleMongoEntity.js.map +1 -1
  105. package/dist/lib/models/StatusExtraData.js +4 -0
  106. package/dist/lib/models/StatusExtraData.js.map +1 -1
  107. package/dist/lib/routes/{AdminRoute.js → BaseAdminRoute.js} +98 -80
  108. package/dist/lib/routes/BaseAdminRoute.js.map +1 -0
  109. package/dist/lib/routes/{MetricsRoute.js → BaseMetricsRoute.js} +29 -15
  110. package/dist/lib/routes/BaseMetricsRoute.js.map +1 -0
  111. package/dist/lib/routes/{OpenAPIRoute.js → BaseOpenAPIRoute.js} +32 -32
  112. package/dist/lib/routes/BaseOpenAPIRoute.js.map +1 -0
  113. package/dist/lib/routes/BasePushRoute.js +305 -0
  114. package/dist/lib/routes/BasePushRoute.js.map +1 -0
  115. package/dist/lib/routes/BaseStaticRoute.js +153 -0
  116. package/dist/lib/routes/BaseStaticRoute.js.map +1 -0
  117. package/dist/lib/routes/BaseStatusRoute.js +80 -0
  118. package/dist/lib/routes/BaseStatusRoute.js.map +1 -0
  119. package/dist/lib/routes/CRUDRoute.js +284 -0
  120. package/dist/lib/routes/CRUDRoute.js.map +1 -0
  121. package/dist/lib/routes/ModelRoute.js +84 -57
  122. package/dist/lib/routes/ModelRoute.js.map +1 -1
  123. package/dist/lib/routes/RouteUtils.js +108 -20
  124. package/dist/lib/routes/RouteUtils.js.map +1 -1
  125. package/dist/lib/routes/index.js +7 -4
  126. package/dist/lib/routes/index.js.map +1 -1
  127. package/dist/lib/security/ACLUtils.js +297 -170
  128. package/dist/lib/security/ACLUtils.js.map +1 -1
  129. package/dist/lib/security/AccessControlList.js +18 -10
  130. package/dist/lib/security/AccessControlList.js.map +1 -1
  131. package/dist/lib/security/AccessControlListMongo.js +19 -68
  132. package/dist/lib/security/AccessControlListMongo.js.map +1 -1
  133. package/dist/lib/security/AccessControlListSQL.js +21 -70
  134. package/dist/lib/security/AccessControlListSQL.js.map +1 -1
  135. package/dist/lib/security/BaseACLRoute.js +239 -0
  136. package/dist/lib/security/BaseACLRoute.js.map +1 -0
  137. package/dist/lib/security/index.js +3 -0
  138. package/dist/lib/security/index.js.map +1 -1
  139. package/dist/lib/test/request.js +62 -5
  140. package/dist/lib/test/request.js.map +1 -1
  141. package/dist/lib/test/requestws.js +34 -10
  142. package/dist/lib/test/requestws.js.map +1 -1
  143. package/dist/types/ApiErrors.d.ts +8 -2
  144. package/dist/types/BackgroundService.d.ts +0 -5
  145. package/dist/types/BackgroundServiceManager.d.ts +2 -1
  146. package/dist/types/EventListenerManager.d.ts +7 -6
  147. package/dist/types/NotificationUtils.d.ts +5 -3
  148. package/dist/types/OpenApiSpec.d.ts +2 -2
  149. package/dist/types/Server.d.ts +28 -10
  150. package/dist/types/auth/AuthMiddleware.d.ts +3 -3
  151. package/dist/types/auth/AuthStrategy.d.ts +10 -7
  152. package/dist/types/auth/JWTStrategy.d.ts +6 -4
  153. package/dist/types/auth/index.d.ts +0 -1
  154. package/dist/types/database/ConnectionKinds.d.ts +7 -0
  155. package/dist/types/database/ConnectionManager.d.ts +29 -4
  156. package/dist/types/database/MongoConnection.d.ts +16 -4
  157. package/dist/types/database/MongoRepository.d.ts +32 -11
  158. package/dist/types/database/RedisCache.d.ts +23 -0
  159. package/dist/types/database/TypeOrmSupport.d.ts +4 -4
  160. package/dist/types/database/index.d.ts +1 -0
  161. package/dist/types/decorators/DatabaseDecorators.d.ts +139 -8
  162. package/dist/types/decorators/DocDecorators.d.ts +11 -2
  163. package/dist/types/decorators/ModelDecorators.d.ts +12 -5
  164. package/dist/types/decorators/PersistenceDecorators.d.ts +11 -4
  165. package/dist/types/decorators/RouteDecorators.d.ts +36 -6
  166. package/dist/types/http/IWebSocketShim.d.ts +11 -0
  167. package/dist/types/http/MiddlewareChain.d.ts +47 -0
  168. package/dist/types/http/RuntimeDetect.d.ts +2 -0
  169. package/dist/types/http/bun/BunAdapters.d.ts +139 -0
  170. package/dist/types/http/bun/BunRouter.d.ts +79 -0
  171. package/dist/types/http/bun/BunWebSocket.d.ts +35 -0
  172. package/dist/types/http/index.d.ts +16 -6
  173. package/dist/types/http/session/RedisSessionStore.d.ts +15 -0
  174. package/dist/types/http/session/SessionManager.d.ts +35 -0
  175. package/dist/types/http/session/SessionStore.d.ts +12 -0
  176. package/dist/types/http/session/sessionMiddleware.d.ts +10 -0
  177. package/dist/types/http/types.d.ts +42 -3
  178. package/dist/types/http/uWS/Adapters.d.ts +129 -0
  179. package/dist/types/http/{Router.d.ts → uWS/Router.d.ts} +14 -38
  180. package/dist/types/http/{WebSocket.d.ts → uWS/WebSocket.d.ts} +6 -5
  181. package/dist/types/models/BaseEntity.d.ts +1 -1
  182. package/dist/types/models/ModelUtils.d.ts +47 -14
  183. package/dist/types/models/RecoverableBaseEntity.d.ts +3 -1
  184. package/dist/types/models/RepoUtils.d.ts +84 -14
  185. package/dist/types/routes/BaseAdminRoute.d.ts +65 -0
  186. package/dist/types/routes/BaseMetricsRoute.d.ts +37 -0
  187. package/dist/types/routes/BaseOpenAPIRoute.d.ts +33 -0
  188. package/dist/types/routes/BasePushRoute.d.ts +53 -0
  189. package/dist/types/routes/BaseStaticRoute.d.ts +44 -0
  190. package/dist/types/routes/BaseStatusRoute.d.ts +37 -0
  191. package/dist/types/routes/CRUDRoute.d.ts +57 -0
  192. package/dist/types/routes/ModelRoute.d.ts +39 -36
  193. package/dist/types/routes/RouteUtils.d.ts +19 -0
  194. package/dist/types/routes/index.d.ts +7 -4
  195. package/dist/types/security/ACLUtils.d.ts +94 -18
  196. package/dist/types/security/AccessControlList.d.ts +37 -59
  197. package/dist/types/security/AccessControlListMongo.d.ts +3 -8
  198. package/dist/types/security/AccessControlListSQL.d.ts +3 -8
  199. package/dist/types/security/BaseACLRoute.d.ts +73 -0
  200. package/dist/types/security/index.d.ts +3 -0
  201. package/dist/types/test/request.d.ts +18 -1
  202. package/package.json +135 -129
  203. package/tsconfig.export.json +17 -0
  204. package/dist/lib/auth/BasicStrategy.js +0 -113
  205. package/dist/lib/auth/BasicStrategy.js.map +0 -1
  206. package/dist/lib/http/Adapters.js +0 -241
  207. package/dist/lib/http/Adapters.js.map +0 -1
  208. package/dist/lib/http/Router.js.map +0 -1
  209. package/dist/lib/http/WebSocket.js.map +0 -1
  210. package/dist/lib/routes/AdminRoute.js.map +0 -1
  211. package/dist/lib/routes/MetricsRoute.js.map +0 -1
  212. package/dist/lib/routes/OpenAPIRoute.js.map +0 -1
  213. package/dist/lib/routes/StatusRoute.js +0 -55
  214. package/dist/lib/routes/StatusRoute.js.map +0 -1
  215. package/dist/lib/security/ACLRouteMongo.js +0 -194
  216. package/dist/lib/security/ACLRouteMongo.js.map +0 -1
  217. package/dist/lib/security/ACLRouteSQL.js +0 -193
  218. package/dist/lib/security/ACLRouteSQL.js.map +0 -1
  219. package/dist/types/auth/BasicStrategy.d.ts +0 -37
  220. package/dist/types/http/Adapters.d.ts +0 -68
  221. package/dist/types/routes/AdminRoute.d.ts +0 -47
  222. package/dist/types/routes/MetricsRoute.d.ts +0 -15
  223. package/dist/types/routes/OpenAPIRoute.d.ts +0 -17
  224. package/dist/types/routes/StatusRoute.d.ts +0 -11
  225. package/dist/types/security/ACLRouteMongo.d.ts +0 -19
  226. package/dist/types/security/ACLRouteSQL.d.ts +0 -19
  227. package/docs/Makefile +0 -20
  228. package/docs/conf.py +0 -58
  229. package/docs/index.rst +0 -17
  230. package/docs/make.bat +0 -35
  231. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/README.md +0 -13
  232. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/MongoRepository.md +0 -25
  233. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/RedisConnection.md +0 -25
  234. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/Repository.md +0 -25
  235. package/docs/reference/@rapidrest/namespaces/DocDecorators/README.md +0 -23
  236. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Default.md +0 -25
  237. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Description.md +0 -25
  238. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Document.md +0 -25
  239. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Example.md +0 -25
  240. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Format.md +0 -25
  241. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Returns.md +0 -28
  242. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Summary.md +0 -25
  243. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Tags.md +0 -25
  244. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/TypeInfo.md +0 -28
  245. package/docs/reference/@rapidrest/namespaces/DocDecorators/interfaces/DocumentsData.md +0 -57
  246. package/docs/reference/@rapidrest/namespaces/EventDecorators/README.md +0 -12
  247. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/EventListener.md +0 -17
  248. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/OnEvent.md +0 -26
  249. package/docs/reference/@rapidrest/namespaces/ModelDecorators/README.md +0 -26
  250. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Cache.md +0 -25
  251. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/ChildEntity.md +0 -18
  252. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/DataStore.md +0 -25
  253. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Identifier.md +0 -27
  254. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Protect.md +0 -35
  255. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Reference.md +0 -25
  256. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Shard.md +0 -27
  257. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/TrackChanges.md +0 -26
  258. package/docs/reference/@rapidrest/namespaces/ModelDecorators/interfaces/PendingTypeOrmColumn.md +0 -45
  259. package/docs/reference/@rapidrest/namespaces/ModelDecorators/variables/pendingTypeOrmColumns.md +0 -14
  260. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/README.md +0 -27
  261. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Column.md +0 -25
  262. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Entity.md +0 -25
  263. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Index.md +0 -119
  264. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/PrimaryColumn.md +0 -25
  265. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Unique.md +0 -68
  266. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getColumnMetadata.md +0 -26
  267. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getEntityName.md +0 -26
  268. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getIndexMetadata.md +0 -27
  269. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/CollationOptions.md +0 -79
  270. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnInfo.md +0 -41
  271. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnOptions.md +0 -51
  272. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/EntityOptions.md +0 -32
  273. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexInfo.md +0 -41
  274. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexOptions.md +0 -61
  275. package/docs/reference/@rapidrest/namespaces/RouteDecorators/README.md +0 -36
  276. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/After.md +0 -26
  277. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Auth.md +0 -33
  278. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/AuthResult.md +0 -31
  279. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Before.md +0 -25
  280. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/ContentType.md +0 -25
  281. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Delete.md +0 -25
  282. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Get.md +0 -25
  283. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Head.md +0 -25
  284. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Header.md +0 -25
  285. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Method.md +0 -31
  286. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Model.md +0 -25
  287. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Options.md +0 -25
  288. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Param.md +0 -26
  289. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Patch.md +0 -25
  290. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Post.md +0 -25
  291. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Protect.md +0 -31
  292. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Put.md +0 -25
  293. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Query.md +0 -26
  294. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Request.md +0 -31
  295. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/RequiresRole.md +0 -26
  296. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Response.md +0 -31
  297. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Route.md +0 -25
  298. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Socket.md +0 -33
  299. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/User.md +0 -31
  300. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Validate.md +0 -25
  301. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/WebSocket.md +0 -25
  302. package/docs/reference/README.md +0 -20
  303. package/docs/reference/classes/ACLUtils.md +0 -263
  304. package/docs/reference/classes/AdminRoute.md +0 -51
  305. package/docs/reference/classes/AuthMiddleware.md +0 -173
  306. package/docs/reference/classes/BackgroundService.md +0 -117
  307. package/docs/reference/classes/BackgroundServiceManager.md +0 -172
  308. package/docs/reference/classes/BaseEntity.md +0 -82
  309. package/docs/reference/classes/BaseMongoEntity.md +0 -107
  310. package/docs/reference/classes/BasicStrategy.md +0 -131
  311. package/docs/reference/classes/BasicStrategyOptions.md +0 -115
  312. package/docs/reference/classes/BulkError.md +0 -271
  313. package/docs/reference/classes/ConnectionManager.md +0 -75
  314. package/docs/reference/classes/EventListenerManager.md +0 -88
  315. package/docs/reference/classes/HttpRouter.md +0 -343
  316. package/docs/reference/classes/JWTStrategy.md +0 -100
  317. package/docs/reference/classes/JWTStrategyOptions.md +0 -97
  318. package/docs/reference/classes/MetricsRoute.md +0 -27
  319. package/docs/reference/classes/ModelRoute.md +0 -527
  320. package/docs/reference/classes/ModelUtils.md +0 -446
  321. package/docs/reference/classes/MongoConnection.md +0 -218
  322. package/docs/reference/classes/MongoRepository.md +0 -390
  323. package/docs/reference/classes/MongoSchemaSync.md +0 -97
  324. package/docs/reference/classes/NetUtils.md +0 -90
  325. package/docs/reference/classes/NotificationUtils.md +0 -77
  326. package/docs/reference/classes/ObjectFactory.md +0 -336
  327. package/docs/reference/classes/OpenAPIRoute.md +0 -77
  328. package/docs/reference/classes/OpenApiSpec.md +0 -892
  329. package/docs/reference/classes/RecoverableBaseEntity.md +0 -114
  330. package/docs/reference/classes/RecoverableBaseMongoEntity.md +0 -124
  331. package/docs/reference/classes/RedisTransport.md +0 -2202
  332. package/docs/reference/classes/RepoUtils.md +0 -482
  333. package/docs/reference/classes/RouteUtils.md +0 -191
  334. package/docs/reference/classes/Server.md +0 -408
  335. package/docs/reference/classes/SimpleEntity.md +0 -48
  336. package/docs/reference/classes/SimpleMongoEntity.md +0 -66
  337. package/docs/reference/classes/StatusExtraData.md +0 -57
  338. package/docs/reference/classes/StatusRoute.md +0 -26
  339. package/docs/reference/classes/UWSRequest.md +0 -226
  340. package/docs/reference/classes/UWSResponse.md +0 -257
  341. package/docs/reference/classes/UWSWebSocketShim.md +0 -958
  342. package/docs/reference/enumerations/ACLAction.md +0 -63
  343. package/docs/reference/enumerations/ApiErrorMessages.md +0 -123
  344. package/docs/reference/enumerations/ApiErrors.md +0 -123
  345. package/docs/reference/functions/createWebSocketStream.md +0 -27
  346. package/docs/reference/functions/isSqlDataSource.md +0 -26
  347. package/docs/reference/functions/readBody.md +0 -29
  348. package/docs/reference/functions/resolveCollectionName.md +0 -33
  349. package/docs/reference/functions/runChain.md +0 -40
  350. package/docs/reference/functions/snakeCase.md +0 -28
  351. package/docs/reference/globals.md +0 -106
  352. package/docs/reference/interfaces/ACLRecord.md +0 -96
  353. package/docs/reference/interfaces/AccessControlList.md +0 -76
  354. package/docs/reference/interfaces/AuthResult.md +0 -55
  355. package/docs/reference/interfaces/AuthStrategy.md +0 -95
  356. package/docs/reference/interfaces/CreateRequestOptions.md +0 -121
  357. package/docs/reference/interfaces/DeleteRequestOptions.md +0 -137
  358. package/docs/reference/interfaces/FindRequestOptions.md +0 -133
  359. package/docs/reference/interfaces/HttpRequest.md +0 -147
  360. package/docs/reference/interfaces/HttpResponse.md +0 -164
  361. package/docs/reference/interfaces/JWTAuthResult.md +0 -84
  362. package/docs/reference/interfaces/RepoCreateOptions.md +0 -95
  363. package/docs/reference/interfaces/RepoDeleteOptions.md +0 -105
  364. package/docs/reference/interfaces/RepoFindOptions.md +0 -125
  365. package/docs/reference/interfaces/RepoOperationOptions.md +0 -69
  366. package/docs/reference/interfaces/RepoUpdateOptions.md +0 -101
  367. package/docs/reference/interfaces/RequestOptions.md +0 -112
  368. package/docs/reference/interfaces/RequestWS.md +0 -225
  369. package/docs/reference/interfaces/TruncateRequestOptions.md +0 -161
  370. package/docs/reference/interfaces/UpdateRequestOptions.md +0 -139
  371. package/docs/reference/type-aliases/ErrorHandler.md +0 -35
  372. package/docs/reference/type-aliases/NextFunction.md +0 -23
  373. package/docs/reference/type-aliases/OneOrMany.md +0 -19
  374. package/docs/reference/type-aliases/OneOrNull.md +0 -19
  375. package/docs/reference/type-aliases/PartialBaseEntity.md +0 -17
  376. package/docs/reference/type-aliases/PartialSimpleEntity.md +0 -17
  377. package/docs/reference/type-aliases/RequestHandler.md +0 -31
  378. package/docs/reference/type-aliases/UpdateObject.md +0 -19
  379. package/docs/reference/type-aliases/WsUpgradeAuth.md +0 -27
  380. package/docs/reference/type-aliases/WsUpgradeAuthResult.md +0 -47
package/package.json CHANGED
@@ -1,129 +1,135 @@
1
- {
2
- "name": "@rapidrest/service-core",
3
- "version": "1.0.0-rc.7",
4
- "description": "Provides all core functionality for RapidREST based backend services.",
5
- "repository": "https://github.com/rapidrest/service-core.git",
6
- "author": "RapidREST <rapidrests@gmail.com>",
7
- "license": "MIT",
8
- "contributors": [
9
- "Jean-Philippe Steinmetz",
10
- "Arthur Thompson",
11
- "Thomas Buscaglia"
12
- ],
13
- "scripts": {
14
- "build": "yarn lint && rimraf dist && tsc",
15
- "deploy-docs": "ts-node tools/gh-pages-publish",
16
- "docs": "typedoc --plugin typedoc-plugin-markdown --out docs/reference src",
17
- "lint": "eslint ./src ./test",
18
- "local-audit": "yarn install && yarn npm audit -A -R \"$@\"",
19
- "checkup": "yarn dlx @yarnpkg/doctor \"$@\"",
20
- "dependency-check": "yarn dlx depcheck \"$@\"",
21
- "report-coverage": "cat ./coverage/lcov.info | coveralls",
22
- "bench": "tsx bench/index.ts",
23
- "bench:baseline": "yarn bench 2>&1 | tee bench/baseline.txt",
24
- "test": "vitest run",
25
- "test:prod": "npm run lint && vitest run --coverage",
26
- "test:watch": "vitest",
27
- "postversion": "git push && git push --tags"
28
- },
29
- "dependencies": {
30
- "axios": "^1.17.0",
31
- "bson": "^7.2.0",
32
- "dayjs": "^1.11.21",
33
- "deepmerge": "^4.3.1",
34
- "node-schedule": "^2.1.1",
35
- "uWebSockets.js": "uNetworking/uWebSockets.js#v20.68.0",
36
- "winston-transport": "^4.9.0",
37
- "ws": "^8.21.0"
38
- },
39
- "peerDependencies": {
40
- "@rapidrest/core": "1.x",
41
- "ioredis": "5.x",
42
- "lodash-es": "4.x",
43
- "mongodb": "^7.0.0",
44
- "openapi3-ts": "4.x",
45
- "prom-client": "15.x",
46
- "reflect-metadata": "0.2.x",
47
- "typeorm": "0.3.x",
48
- "uWebSockets.js": "*",
49
- "winston": "3.x"
50
- },
51
- "peerDependenciesMeta": {
52
- "ioredis": {
53
- "optional": true
54
- },
55
- "mongodb": {
56
- "optional": true
57
- },
58
- "typeorm": {
59
- "optional": true
60
- }
61
- },
62
- "devDependencies": {
63
- "@rapidrest/core": "^1.3.0",
64
- "@swc/core": "^1.15.41",
65
- "@types/ioredis-mock": "^8.2.7",
66
- "@types/node": "^25.9.2",
67
- "@types/node-schedule": "^2.1.8",
68
- "@types/rimraf": "^4.0.5",
69
- "@types/sqlite3": "^5.1.0",
70
- "@types/uuid": "^11.0.0",
71
- "@types/ws": "^8.18.1",
72
- "@typescript-eslint/eslint-plugin": "^8.61.0",
73
- "@typescript-eslint/parser": "^8.61.0",
74
- "@vitest/coverage-v8": "^4.1.8",
75
- "autocannon": "^8.0.0",
76
- "coveralls": "^3.1.1",
77
- "eslint": "^10.4.1",
78
- "eslint-config-prettier": "^10.1.8",
79
- "eslint-plugin-import": "^2.32.0",
80
- "eslint-plugin-jsdoc": "^63.0.2",
81
- "globals": "^17.6.0",
82
- "ioredis": "^5.11.1",
83
- "ioredis-mock": "^8.13.1",
84
- "lodash-es": "^4.18.1",
85
- "mongodb": "^7.3.0",
86
- "mongodb-memory-server": "^11.2.0",
87
- "nconf": "^0.13.0",
88
- "openapi3-ts": "^4.6.0",
89
- "pg": "^8.21.0",
90
- "prom-client": "^15.1.3",
91
- "reflect-metadata": "^0.2.2",
92
- "rimraf": "^6.1.3",
93
- "sqlite3": "^6.0.1",
94
- "ts-node": "^10.9.2",
95
- "tsx": "^4.19.3",
96
- "typedoc": "^0.28.19",
97
- "typedoc-plugin-markdown": "^4.12.0",
98
- "typeorm": "^0.3.20",
99
- "typescript": "^6.0.3",
100
- "unplugin-swc": "^1.5.9",
101
- "uuid": "^14.0.0",
102
- "vitest": "^4.1.8",
103
- "winston": "^3.19.0",
104
- "ws": "^8.21.0"
105
- },
106
- "resolutions": {
107
- "cross-spawn": "^7.0.5"
108
- },
109
- "packageManager": "yarn@4.5.3",
110
- "engines": {
111
- "node": ">=24.0.0"
112
- },
113
- "publishConfig": {
114
- "registry": "https://registry.npmjs.org/"
115
- },
116
- "type": "module",
117
- "main": "dist/lib/index.js",
118
- "exports": {
119
- ".": {
120
- "import": "./dist/lib/index.js",
121
- "types": "./dist/types/index.d.ts"
122
- }
123
- },
124
- "typings": "dist/types/index.d.ts",
125
- "files": [
126
- "dist",
127
- "docs"
128
- ]
129
- }
1
+ {
2
+ "name": "@rapidrest/service-core",
3
+ "version": "1.0.0",
4
+ "description": "Provides all core functionality for RapidREST based backend services.",
5
+ "repository": "https://github.com/rapidrest/service-core.git",
6
+ "author": "RapidREST <rapidrests@gmail.com>",
7
+ "license": "MPL-2.0",
8
+ "contributors": [
9
+ "Jean-Philippe Steinmetz",
10
+ "Arthur Thompson",
11
+ "Thomas Buscaglia"
12
+ ],
13
+ "scripts": {
14
+ "build": "yarn lint && rimraf dist && tsc",
15
+ "lint": "eslint ./src ./test",
16
+ "local-audit": "yarn install && yarn npm audit -A -R \"$@\"",
17
+ "checkup": "yarn dlx @yarnpkg/doctor \"$@\"",
18
+ "dependency-check": "yarn dlx depcheck \"$@\"",
19
+ "bench": "tsx bench/index.ts",
20
+ "bench:baseline": "yarn bench 2>&1 | tee bench/baseline.txt",
21
+ "test": "vitest run",
22
+ "test:prod": "npm run lint && vitest run --coverage",
23
+ "test:watch": "vitest",
24
+ "postversion": "git push && git push --tags"
25
+ },
26
+ "dependencies": {
27
+ "axios": "^1.17.0",
28
+ "dayjs": "^1.11.21",
29
+ "deepmerge": "^4.3.1",
30
+ "node-schedule": "^2.1.1",
31
+ "winston-transport": "^4.9.0",
32
+ "ws": "^8.21.0"
33
+ },
34
+ "optionalDependencies": {
35
+ "uWebSockets.js": "uNetworking/uWebSockets.js#v20.68.0"
36
+ },
37
+ "peerDependencies": {
38
+ "@rapidrest/core": "3.x",
39
+ "lodash-es": "4.x",
40
+ "mongodb": "^7.0.0",
41
+ "openapi3-ts": "4.x",
42
+ "prom-client": "15.x",
43
+ "redis": "6.x",
44
+ "reflect-metadata": "0.2.x",
45
+ "typeorm": "1.1.x",
46
+ "uWebSockets.js": "*",
47
+ "winston": "3.x"
48
+ },
49
+ "peerDependenciesMeta": {
50
+ "mongodb": {
51
+ "optional": true
52
+ },
53
+ "typeorm": {
54
+ "optional": true
55
+ },
56
+ "uWebSockets.js": {
57
+ "optional": true
58
+ }
59
+ },
60
+ "devDependencies": {
61
+ "@rapidrest/core": "^4.0.0",
62
+ "@simplewebauthn/server": "^13.3.2",
63
+ "@swc/core": "^1.15.41",
64
+ "@types/better-sqlite3": "^9.6.0",
65
+ "@types/bun": "^1.3.14",
66
+ "@types/node": "^25.9.2",
67
+ "@types/node-schedule": "^2.1.8",
68
+ "@types/rimraf": "^4.0.5",
69
+ "@types/speakeasy": "^2",
70
+ "@types/uuid": "^11.0.0",
71
+ "@types/ws": "^8.18.1",
72
+ "@typescript-eslint/eslint-plugin": "^8.61.0",
73
+ "@typescript-eslint/parser": "^8.61.0",
74
+ "@vitest/coverage-v8": "^4.1.8",
75
+ "autocannon": "^8.0.0",
76
+ "better-sqlite3": "^12.0.0",
77
+ "eslint": "^10.4.1",
78
+ "eslint-config-prettier": "^10.1.8",
79
+ "eslint-plugin-import": "^2.32.0",
80
+ "eslint-plugin-jsdoc": "^63.0.2",
81
+ "globals": "^17.6.0",
82
+ "lodash-es": "^4.18.1",
83
+ "mongodb": "^7.3.0",
84
+ "mongodb-memory-server": "^11.2.0",
85
+ "nconf": "^0.13.0",
86
+ "nock": "^14.0.16",
87
+ "openapi3-ts": "^4.6.0",
88
+ "pg": "^8.21.0",
89
+ "prom-client": "^15.1.3",
90
+ "redis": "^6.2.1",
91
+ "reflect-metadata": "^0.2.2",
92
+ "rimraf": "^6.1.3",
93
+ "ts-node": "^10.9.2",
94
+ "tsx": "^4.19.3",
95
+ "typedoc": "^0.28.19",
96
+ "typedoc-plugin-markdown": "^4.12.0",
97
+ "typeorm": "^1.1.0",
98
+ "typescript": "^6.0.3",
99
+ "unplugin-swc": "^1.5.9",
100
+ "uuid": "^14.0.0",
101
+ "vitest": "^4.1.8",
102
+ "winston": "^3.19.0",
103
+ "ws": "^8.21.0"
104
+ },
105
+ "resolutions": {
106
+ "cross-spawn": "^7.0.5",
107
+ "uuid@npm:^8.3.2": "^11.1.1"
108
+ },
109
+ "packageManager": "yarn@4.5.3",
110
+ "engines": {
111
+ "node": ">=24.0.0"
112
+ },
113
+ "publishConfig": {
114
+ "registry": "https://registry.npmjs.org/"
115
+ },
116
+ "type": "module",
117
+ "main": "dist/lib/index.js",
118
+ "exports": {
119
+ ".": {
120
+ "import": "./dist/lib/index.js",
121
+ "types": "./dist/types/index.d.ts"
122
+ },
123
+ "./test": {
124
+ "import": "./dist/lib/test/index.js",
125
+ "types": "./dist/types/test/index.d.ts"
126
+ },
127
+ "./tsconfig": "./tsconfig.export.json"
128
+ },
129
+ "typings": "dist/types/index.d.ts",
130
+ "files": [
131
+ "dist",
132
+ "docs",
133
+ "tsconfig.export.json"
134
+ ]
135
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "moduleResolution": "NodeNext",
4
+ "target": "ES2020",
5
+ "module": "NodeNext",
6
+ "strict": true,
7
+ "sourceMap": false,
8
+ "declaration": false,
9
+ "allowSyntheticDefaultImports": true,
10
+ "experimentalDecorators": true,
11
+ "emitDecoratorMetadata": true,
12
+ "noImplicitAny": false,
13
+ "rootDir": "src",
14
+ "outDir": "dist"
15
+ },
16
+ "include": ["src"]
17
+ }
@@ -1,113 +0,0 @@
1
- /**
2
- * Describes the configuration options that can be used to initialize BasicStrategy.
3
- *
4
- * @author Jean-Philippe Steinmetz
5
- */
6
- export class BasicStrategyOptions {
7
- constructor() {
8
- /** The name of the header to look for when performing header based authentication. Default value is `Authorization`. */
9
- this.headerKey = "authorization";
10
- /** The authorization scheme type when using header based authentication. Default value is `jwt`. */
11
- this.headerScheme = "basic";
12
- /** The name of the request query parameter to retrieve the token from when using query based authentication. Default value is `auth_basic`. */
13
- this.queryKey = "auth_basic";
14
- /**
15
- * Set to `true` to allow credentials to be supplied via the `queryKey` URL parameter.
16
- * Disabled by default — query parameters appear in server logs, browser history, and
17
- * Referer headers, which permanently exposes credentials outside the application.
18
- */
19
- this.allowQueryParam = false;
20
- }
21
- /** Override this function to handle asynchronous (non-blocking) verification of the login info. */
22
- verify(uid, secret) {
23
- throw new Error("Did you forget to override BasicStrategyOptions.verify?");
24
- }
25
- /** Override this function to handle synchronous (blocking) verification of the login info. */
26
- verifySync(uid, secret) {
27
- throw new Error("Did you forget to override BasicStrategyOptions.verifySync?");
28
- }
29
- }
30
- /**
31
- * @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
32
- */
33
- export class BasicStrategy {
34
- constructor(options = new BasicStrategyOptions()) {
35
- this.name = "basic";
36
- this.options = options;
37
- }
38
- getLoginInfo(req) {
39
- let loginInfo = "";
40
- // Login info should be found in this order: Query Parameter => Authorization
41
- // Check the query parameter (only when explicitly opted in — tokens in URLs appear in logs)
42
- if (this.options.allowQueryParam && this.options.queryKey && req.query && this.options.queryKey in req.query) {
43
- loginInfo = req.query[this.options.queryKey];
44
- }
45
- // Next check the headers. It's possible there is more than one header value defined. Loop through each of
46
- // them until we have a verified login info.
47
- if (!loginInfo && this.options.headerKey && this.options.headerKey in req.headers) {
48
- const value = req.headers[this.options.headerKey];
49
- const headers = Array.isArray(value) ? value : typeof value === "string" ? [value] : [];
50
- // Loop throught th
51
- for (const header in headers) {
52
- const parts = headers[header].split(" ");
53
- if (parts.length !== 2) {
54
- continue;
55
- }
56
- if (!parts[0].match(new RegExp("^" + this.options.headerScheme + "$", "i"))) {
57
- continue;
58
- }
59
- loginInfo = parts[1];
60
- }
61
- }
62
- return loginInfo;
63
- }
64
- async authenticate(req, res, required) {
65
- let loginInfo = this.getLoginInfo(req);
66
- // If the login info has been found, verify it.
67
- if (loginInfo && loginInfo.length > 0) {
68
- const info = Buffer.from(loginInfo, "base64").toString("utf-8");
69
- const parts = info.split(":");
70
- if (parts.length !== 2) {
71
- throw new Error("Invalid username or password.");
72
- }
73
- const user = await this.options.verify(parts[0], parts[1]);
74
- if (user) {
75
- return {
76
- data: loginInfo,
77
- method: this.name,
78
- payload: info,
79
- user,
80
- };
81
- }
82
- }
83
- if (required) {
84
- throw new Error("Invalid username or password.");
85
- }
86
- return undefined;
87
- }
88
- authenticateSync(req, res, required) {
89
- let loginInfo = this.getLoginInfo(req);
90
- // If the login info has been found, verify it.
91
- if (loginInfo && loginInfo.length > 0) {
92
- const info = Buffer.from(loginInfo, "base64").toString("utf-8");
93
- const parts = info.split(":");
94
- if (parts.length !== 2) {
95
- throw new Error("Invalid username or password.");
96
- }
97
- const user = this.options.verifySync(parts[0], parts[1]);
98
- if (user) {
99
- return {
100
- data: loginInfo,
101
- method: this.name,
102
- payload: info,
103
- user,
104
- };
105
- }
106
- }
107
- if (required) {
108
- throw new Error("Invalid username or password.");
109
- }
110
- return undefined;
111
- }
112
- }
113
- //# sourceMappingURL=BasicStrategy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BasicStrategy.js","sourceRoot":"","sources":["../../../src/auth/BasicStrategy.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IAAjC;QACI,wHAAwH;QACjH,cAAS,GAAW,eAAe,CAAC;QAC3C,oGAAoG;QAC7F,iBAAY,GAAW,OAAO,CAAC;QACtC,+IAA+I;QACxI,aAAQ,GAAW,YAAY,CAAC;QACvC;;;;WAIG;QACI,oBAAe,GAAY,KAAK,CAAC;IAS5C,CAAC;IARG,mGAAmG;IAC5F,MAAM,CAAC,GAAW,EAAE,MAAc;QACrC,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC/E,CAAC;IACD,8FAA8F;IACvF,UAAU,CAAC,GAAW,EAAE,MAAc;QACzC,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACnF,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,aAAa;IAItB,YAAY,UAAgC,IAAI,oBAAoB,EAAE;QAHtD,SAAI,GAAW,OAAO,CAAC;QAInC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAEO,YAAY,CAAC,GAAgB;QACjC,IAAI,SAAS,GAAW,EAAE,CAAC;QAE3B,6EAA6E;QAC7E,4FAA4F;QAC5F,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;YAC3G,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAW,CAAC;QAC3D,CAAC;QAED,0GAA0G;QAC1G,4CAA4C;QAC5C,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAChF,MAAM,KAAK,GAAkC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACjF,MAAM,OAAO,GAAa,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAElG,mBAAmB;YACnB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC3B,MAAM,KAAK,GAAa,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACnD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACrB,SAAS;gBACb,CAAC;gBAED,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;oBAC1E,SAAS;gBACb,CAAC;gBAED,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACzB,CAAC;QACL,CAAC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,YAAY,CACrB,GAAgB,EAChB,GAAiB,EACjB,QAAkB;QAElB,IAAI,SAAS,GAAW,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QAE/C,+CAA+C;QAC/C,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,GAAW,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACxE,MAAM,KAAK,GAAa,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACxC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACrB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,IAAI,GAAwB,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAChF,IAAI,IAAI,EAAE,CAAC;gBACP,OAAO;oBACH,IAAI,EAAE,SAAS;oBACf,MAAM,EAAE,IAAI,CAAC,IAAI;oBACjB,OAAO,EAAE,IAAI;oBACb,IAAI;iBACP,CAAC;YACN,CAAC;QACL,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAEM,gBAAgB,CAAC,GAAgB,EAAE,GAAiB,EAAE,QAAkB;QAC3E,IAAI,SAAS,GAAW,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QAE/C,+CAA+C;QAC/C,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,GAAW,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACxE,MAAM,KAAK,GAAa,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACxC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACrB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;YACrD,CAAC;YACD,MAAM,IAAI,GAAwB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9E,IAAI,IAAI,EAAE,CAAC;gBACP,OAAO;oBACH,IAAI,EAAE,SAAS;oBACf,MAAM,EAAE,IAAI,CAAC,IAAI;oBACjB,OAAO,EAAE,IAAI;oBACb,IAAI;iBACP,CAAC;YACN,CAAC;QACL,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
@@ -1,241 +0,0 @@
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
- let hasChunks = false;
200
- const chunks = [];
201
- const parseBody = (raw) => {
202
- req.rawBody = raw;
203
- if (raw.length > 0) {
204
- const contentType = String(req.headers["content-type"] || "").toLowerCase();
205
- if (contentType.includes("application/json")) {
206
- try {
207
- req.body = JSON.parse(raw.toString("utf8"));
208
- }
209
- catch {
210
- req.body = raw.toString("utf8");
211
- }
212
- }
213
- else if (contentType.includes("application/x-www-form-urlencoded")) {
214
- req.body = Object.fromEntries(new URLSearchParams(raw.toString("utf8")).entries());
215
- }
216
- else {
217
- req.body = raw;
218
- }
219
- }
220
- else {
221
- req.body = undefined;
222
- }
223
- };
224
- uwsRes.onData((chunk, isLast) => {
225
- if (isLast && !hasChunks) {
226
- // Fast path: single-chunk body — skip the chunks array and Buffer.concat entirely.
227
- parseBody(Buffer.from(chunk));
228
- resolve();
229
- return;
230
- }
231
- // Multi-chunk path: copy each chunk (ArrayBuffer is only valid during this callback).
232
- hasChunks = true;
233
- chunks.push(Buffer.from(chunk));
234
- if (isLast) {
235
- parseBody(Buffer.concat(chunks));
236
- resolve();
237
- }
238
- });
239
- });
240
- }
241
- //# sourceMappingURL=Adapters.js.map