@rapidrest/service-core 1.0.0-rc.2 → 1.0.0-rc.21

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 (250) hide show
  1. package/dist/lib/BackgroundService.js +0 -4
  2. package/dist/lib/BackgroundService.js.map +1 -1
  3. package/dist/lib/BackgroundServiceManager.js +21 -4
  4. package/dist/lib/BackgroundServiceManager.js.map +1 -1
  5. package/dist/lib/EventListenerManager.js.map +1 -1
  6. package/dist/lib/OpenApiSpec.js +3 -2
  7. package/dist/lib/OpenApiSpec.js.map +1 -1
  8. package/dist/lib/Server.js +18 -79
  9. package/dist/lib/Server.js.map +1 -1
  10. package/dist/lib/database/TypeOrmSupport.js +18 -2
  11. package/dist/lib/database/TypeOrmSupport.js.map +1 -1
  12. package/dist/lib/decorators/DocDecorators.js +19 -1
  13. package/dist/lib/decorators/DocDecorators.js.map +1 -1
  14. package/dist/lib/decorators/PersistenceDecorators.js.map +1 -1
  15. package/dist/lib/decorators/RouteDecorators.js +71 -20
  16. package/dist/lib/decorators/RouteDecorators.js.map +1 -1
  17. package/dist/lib/http/Adapters.js +45 -2
  18. package/dist/lib/http/Adapters.js.map +1 -1
  19. package/dist/lib/http/Router.js +53 -56
  20. package/dist/lib/http/Router.js.map +1 -1
  21. package/dist/lib/models/ModelUtils.js +18 -8
  22. package/dist/lib/models/ModelUtils.js.map +1 -1
  23. package/dist/lib/models/RepoUtils.js +96 -31
  24. package/dist/lib/models/RepoUtils.js.map +1 -1
  25. package/dist/lib/routes/{AdminRoute.js → BaseAdminRoute.js} +51 -36
  26. package/dist/lib/routes/BaseAdminRoute.js.map +1 -0
  27. package/dist/lib/routes/{MetricsRoute.js → BaseMetricsRoute.js} +28 -15
  28. package/dist/lib/routes/BaseMetricsRoute.js.map +1 -0
  29. package/dist/lib/routes/{OpenAPIRoute.js → BaseOpenAPIRoute.js} +31 -32
  30. package/dist/lib/routes/BaseOpenAPIRoute.js.map +1 -0
  31. package/dist/lib/routes/BasePushRoute.js +193 -0
  32. package/dist/lib/routes/BasePushRoute.js.map +1 -0
  33. package/dist/lib/routes/BaseStaticRoute.js +152 -0
  34. package/dist/lib/routes/BaseStaticRoute.js.map +1 -0
  35. package/dist/lib/routes/BaseStatusRoute.js +79 -0
  36. package/dist/lib/routes/BaseStatusRoute.js.map +1 -0
  37. package/dist/lib/routes/CRUDRoute.js +238 -0
  38. package/dist/lib/routes/CRUDRoute.js.map +1 -0
  39. package/dist/lib/routes/ModelRoute.js +20 -28
  40. package/dist/lib/routes/ModelRoute.js.map +1 -1
  41. package/dist/lib/routes/index.js +7 -4
  42. package/dist/lib/routes/index.js.map +1 -1
  43. package/dist/lib/security/ACLUtils.js +10 -13
  44. package/dist/lib/security/ACLUtils.js.map +1 -1
  45. package/dist/lib/security/AccessControlListMongo.js +5 -1
  46. package/dist/lib/security/AccessControlListMongo.js.map +1 -1
  47. package/dist/lib/security/AccessControlListSQL.js +7 -3
  48. package/dist/lib/security/AccessControlListSQL.js.map +1 -1
  49. package/dist/lib/security/BaseACLRoute.js +239 -0
  50. package/dist/lib/security/BaseACLRoute.js.map +1 -0
  51. package/dist/lib/security/index.js +3 -0
  52. package/dist/lib/security/index.js.map +1 -1
  53. package/dist/lib/test/request.js +6 -2
  54. package/dist/lib/test/request.js.map +1 -1
  55. package/dist/types/BackgroundService.d.ts +0 -5
  56. package/dist/types/BackgroundServiceManager.d.ts +1 -1
  57. package/dist/types/EventListenerManager.d.ts +4 -4
  58. package/dist/types/Server.d.ts +21 -6
  59. package/dist/types/decorators/DocDecorators.d.ts +9 -0
  60. package/dist/types/decorators/PersistenceDecorators.d.ts +7 -0
  61. package/dist/types/decorators/RouteDecorators.d.ts +14 -5
  62. package/dist/types/http/Adapters.d.ts +19 -0
  63. package/dist/types/http/Router.d.ts +6 -6
  64. package/dist/types/models/ModelUtils.d.ts +2 -1
  65. package/dist/types/routes/BaseAdminRoute.d.ts +59 -0
  66. package/dist/types/routes/BaseMetricsRoute.d.ts +37 -0
  67. package/dist/types/routes/BaseOpenAPIRoute.d.ts +33 -0
  68. package/dist/types/routes/BasePushRoute.d.ts +39 -0
  69. package/dist/types/routes/BaseStaticRoute.d.ts +44 -0
  70. package/dist/types/routes/BaseStatusRoute.d.ts +37 -0
  71. package/dist/types/routes/CRUDRoute.d.ts +47 -0
  72. package/dist/types/routes/ModelRoute.d.ts +23 -16
  73. package/dist/types/routes/index.d.ts +7 -4
  74. package/dist/types/security/ACLUtils.d.ts +1 -1
  75. package/dist/types/security/AccessControlList.d.ts +1 -1
  76. package/dist/types/security/AccessControlListMongo.d.ts +1 -1
  77. package/dist/types/security/AccessControlListSQL.d.ts +1 -1
  78. package/dist/types/security/BaseACLRoute.d.ts +73 -0
  79. package/dist/types/security/index.d.ts +3 -0
  80. package/package.json +132 -129
  81. package/tsconfig.export.json +17 -0
  82. package/dist/lib/routes/AdminRoute.js.map +0 -1
  83. package/dist/lib/routes/MetricsRoute.js.map +0 -1
  84. package/dist/lib/routes/OpenAPIRoute.js.map +0 -1
  85. package/dist/lib/routes/StatusRoute.js +0 -55
  86. package/dist/lib/routes/StatusRoute.js.map +0 -1
  87. package/dist/lib/security/ACLRouteMongo.js +0 -194
  88. package/dist/lib/security/ACLRouteMongo.js.map +0 -1
  89. package/dist/lib/security/ACLRouteSQL.js +0 -193
  90. package/dist/lib/security/ACLRouteSQL.js.map +0 -1
  91. package/dist/types/routes/AdminRoute.d.ts +0 -47
  92. package/dist/types/routes/MetricsRoute.d.ts +0 -15
  93. package/dist/types/routes/OpenAPIRoute.d.ts +0 -17
  94. package/dist/types/routes/StatusRoute.d.ts +0 -11
  95. package/dist/types/security/ACLRouteMongo.d.ts +0 -19
  96. package/dist/types/security/ACLRouteSQL.d.ts +0 -19
  97. package/docs/Makefile +0 -20
  98. package/docs/conf.py +0 -58
  99. package/docs/index.rst +0 -17
  100. package/docs/make.bat +0 -35
  101. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/README.md +0 -13
  102. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/MongoRepository.md +0 -25
  103. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/RedisConnection.md +0 -25
  104. package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/Repository.md +0 -25
  105. package/docs/reference/@rapidrest/namespaces/DocDecorators/README.md +0 -23
  106. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Default.md +0 -25
  107. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Description.md +0 -25
  108. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Document.md +0 -25
  109. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Example.md +0 -25
  110. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Format.md +0 -25
  111. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Returns.md +0 -28
  112. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Summary.md +0 -25
  113. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Tags.md +0 -25
  114. package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/TypeInfo.md +0 -28
  115. package/docs/reference/@rapidrest/namespaces/DocDecorators/interfaces/DocumentsData.md +0 -57
  116. package/docs/reference/@rapidrest/namespaces/EventDecorators/README.md +0 -12
  117. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/EventListener.md +0 -17
  118. package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/OnEvent.md +0 -26
  119. package/docs/reference/@rapidrest/namespaces/ModelDecorators/README.md +0 -26
  120. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Cache.md +0 -25
  121. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/ChildEntity.md +0 -18
  122. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/DataStore.md +0 -25
  123. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Identifier.md +0 -27
  124. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Protect.md +0 -35
  125. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Reference.md +0 -25
  126. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Shard.md +0 -27
  127. package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/TrackChanges.md +0 -26
  128. package/docs/reference/@rapidrest/namespaces/ModelDecorators/interfaces/PendingTypeOrmColumn.md +0 -45
  129. package/docs/reference/@rapidrest/namespaces/ModelDecorators/variables/pendingTypeOrmColumns.md +0 -14
  130. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/README.md +0 -27
  131. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Column.md +0 -25
  132. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Entity.md +0 -25
  133. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Index.md +0 -119
  134. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/PrimaryColumn.md +0 -25
  135. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Unique.md +0 -68
  136. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getColumnMetadata.md +0 -26
  137. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getEntityName.md +0 -26
  138. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getIndexMetadata.md +0 -27
  139. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/CollationOptions.md +0 -79
  140. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnInfo.md +0 -41
  141. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnOptions.md +0 -51
  142. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/EntityOptions.md +0 -32
  143. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexInfo.md +0 -41
  144. package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexOptions.md +0 -61
  145. package/docs/reference/@rapidrest/namespaces/RouteDecorators/README.md +0 -36
  146. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/After.md +0 -26
  147. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Auth.md +0 -33
  148. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/AuthResult.md +0 -31
  149. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Before.md +0 -25
  150. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/ContentType.md +0 -25
  151. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Delete.md +0 -25
  152. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Get.md +0 -25
  153. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Head.md +0 -25
  154. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Header.md +0 -25
  155. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Method.md +0 -31
  156. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Model.md +0 -25
  157. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Options.md +0 -25
  158. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Param.md +0 -26
  159. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Patch.md +0 -25
  160. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Post.md +0 -25
  161. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Protect.md +0 -31
  162. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Put.md +0 -25
  163. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Query.md +0 -26
  164. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Request.md +0 -31
  165. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/RequiresRole.md +0 -26
  166. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Response.md +0 -31
  167. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Route.md +0 -25
  168. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Socket.md +0 -33
  169. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/User.md +0 -31
  170. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Validate.md +0 -25
  171. package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/WebSocket.md +0 -25
  172. package/docs/reference/README.md +0 -20
  173. package/docs/reference/classes/ACLUtils.md +0 -263
  174. package/docs/reference/classes/AdminRoute.md +0 -51
  175. package/docs/reference/classes/AuthMiddleware.md +0 -173
  176. package/docs/reference/classes/BackgroundService.md +0 -117
  177. package/docs/reference/classes/BackgroundServiceManager.md +0 -172
  178. package/docs/reference/classes/BaseEntity.md +0 -82
  179. package/docs/reference/classes/BaseMongoEntity.md +0 -107
  180. package/docs/reference/classes/BasicStrategy.md +0 -131
  181. package/docs/reference/classes/BasicStrategyOptions.md +0 -115
  182. package/docs/reference/classes/BulkError.md +0 -271
  183. package/docs/reference/classes/ConnectionManager.md +0 -75
  184. package/docs/reference/classes/EventListenerManager.md +0 -88
  185. package/docs/reference/classes/HttpRouter.md +0 -343
  186. package/docs/reference/classes/JWTStrategy.md +0 -100
  187. package/docs/reference/classes/JWTStrategyOptions.md +0 -97
  188. package/docs/reference/classes/MetricsRoute.md +0 -27
  189. package/docs/reference/classes/ModelRoute.md +0 -527
  190. package/docs/reference/classes/ModelUtils.md +0 -430
  191. package/docs/reference/classes/MongoConnection.md +0 -218
  192. package/docs/reference/classes/MongoRepository.md +0 -390
  193. package/docs/reference/classes/MongoSchemaSync.md +0 -97
  194. package/docs/reference/classes/NetUtils.md +0 -90
  195. package/docs/reference/classes/NotificationUtils.md +0 -77
  196. package/docs/reference/classes/ObjectFactory.md +0 -336
  197. package/docs/reference/classes/OpenAPIRoute.md +0 -77
  198. package/docs/reference/classes/OpenApiSpec.md +0 -892
  199. package/docs/reference/classes/RecoverableBaseEntity.md +0 -114
  200. package/docs/reference/classes/RecoverableBaseMongoEntity.md +0 -124
  201. package/docs/reference/classes/RedisTransport.md +0 -2202
  202. package/docs/reference/classes/RepoUtils.md +0 -482
  203. package/docs/reference/classes/RouteUtils.md +0 -191
  204. package/docs/reference/classes/Server.md +0 -408
  205. package/docs/reference/classes/SimpleEntity.md +0 -48
  206. package/docs/reference/classes/SimpleMongoEntity.md +0 -66
  207. package/docs/reference/classes/StatusExtraData.md +0 -57
  208. package/docs/reference/classes/StatusRoute.md +0 -26
  209. package/docs/reference/classes/UWSRequest.md +0 -226
  210. package/docs/reference/classes/UWSResponse.md +0 -257
  211. package/docs/reference/classes/UWSWebSocketShim.md +0 -958
  212. package/docs/reference/enumerations/ACLAction.md +0 -63
  213. package/docs/reference/enumerations/ApiErrorMessages.md +0 -123
  214. package/docs/reference/enumerations/ApiErrors.md +0 -123
  215. package/docs/reference/functions/createWebSocketStream.md +0 -27
  216. package/docs/reference/functions/isSqlDataSource.md +0 -26
  217. package/docs/reference/functions/readBody.md +0 -29
  218. package/docs/reference/functions/resolveCollectionName.md +0 -33
  219. package/docs/reference/functions/runChain.md +0 -40
  220. package/docs/reference/functions/snakeCase.md +0 -28
  221. package/docs/reference/globals.md +0 -106
  222. package/docs/reference/interfaces/ACLRecord.md +0 -96
  223. package/docs/reference/interfaces/AccessControlList.md +0 -76
  224. package/docs/reference/interfaces/AuthResult.md +0 -55
  225. package/docs/reference/interfaces/AuthStrategy.md +0 -95
  226. package/docs/reference/interfaces/CreateRequestOptions.md +0 -121
  227. package/docs/reference/interfaces/DeleteRequestOptions.md +0 -137
  228. package/docs/reference/interfaces/FindRequestOptions.md +0 -133
  229. package/docs/reference/interfaces/HttpRequest.md +0 -147
  230. package/docs/reference/interfaces/HttpResponse.md +0 -164
  231. package/docs/reference/interfaces/JWTAuthResult.md +0 -84
  232. package/docs/reference/interfaces/RepoCreateOptions.md +0 -95
  233. package/docs/reference/interfaces/RepoDeleteOptions.md +0 -105
  234. package/docs/reference/interfaces/RepoFindOptions.md +0 -125
  235. package/docs/reference/interfaces/RepoOperationOptions.md +0 -69
  236. package/docs/reference/interfaces/RepoUpdateOptions.md +0 -101
  237. package/docs/reference/interfaces/RequestOptions.md +0 -112
  238. package/docs/reference/interfaces/RequestWS.md +0 -225
  239. package/docs/reference/interfaces/TruncateRequestOptions.md +0 -161
  240. package/docs/reference/interfaces/UpdateRequestOptions.md +0 -139
  241. package/docs/reference/type-aliases/ErrorHandler.md +0 -35
  242. package/docs/reference/type-aliases/NextFunction.md +0 -23
  243. package/docs/reference/type-aliases/OneOrMany.md +0 -19
  244. package/docs/reference/type-aliases/OneOrNull.md +0 -19
  245. package/docs/reference/type-aliases/PartialBaseEntity.md +0 -17
  246. package/docs/reference/type-aliases/PartialSimpleEntity.md +0 -17
  247. package/docs/reference/type-aliases/RequestHandler.md +0 -31
  248. package/docs/reference/type-aliases/UpdateObject.md +0 -19
  249. package/docs/reference/type-aliases/WsUpgradeAuth.md +0 -27
  250. package/docs/reference/type-aliases/WsUpgradeAuthResult.md +0 -47
@@ -16,7 +16,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
16
16
  import { ApiError, ObjectDecorators, UserUtils } from "@rapidrest/core";
17
17
  import { Redis } from "ioredis";
18
18
  import Transport from "winston-transport";
19
- import { Auth, ContentType, Get, Route, Socket, User, WebSocket } from "../decorators/RouteDecorators.js";
19
+ import { Auth, ContentType, Get, Socket, User, WebSocket } from "../decorators/RouteDecorators.js";
20
20
  import { RedisConnection } from "../decorators/DatabaseDecorators.js";
21
21
  import { Description, Returns, Summary } from "../decorators/DocDecorators.js";
22
22
  import { ApiErrorMessages, ApiErrors } from "../ApiErrors.js";
@@ -39,29 +39,45 @@ export class RedisTransport extends Transport {
39
39
  }
40
40
  }
41
41
  /**
42
- * The `AdminRoute` provides a default `/admin` endpoint that gives trusted users the following abilities:
42
+ * The `BaseAdminRoute` class provides a base set of endpoints that gives trusted users the ability to perform common adminstrative actions
43
+ * with the server.
43
44
  *
44
- * * Clear cache via `GET /admin/clear-cache`
45
- * * Live tail the service logs via `GET /admin/logs`
46
- * * Retrieve service dependencies via `GET /admin/dependencies`
47
- * * Retrieve service release notes via `GET /admin/release-notes`
48
- * * Restart the service via `GET /admin/restart`
45
+ * Exposed endpoints:
46
+ *
47
+ * | Name | HTTP Method | What it does |
48
+ * | --- | --- | --- |
49
+ * | `clearCache` | `GET /<base_path>/clear-cache` | Clears the Redis-based cache system. |
50
+ * | `logs` | `UPGRADE /<base_path>/logs` | Live tail the service logs |
51
+ * | `getReleaseNotes` | `GET /<base_path>/release-notes` | Retrieve the server release notes. |
52
+ * | `restart` | `GET /<base_path>/restart` | ` Restart the server |
53
+ *
54
+ * !!Note!! that the `BaseAdminRoute` is not automatically registered with a server by default. You must create
55
+ * your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import { BaseAdminRoute, RouteDecorators } from "@rapidrest/service-core";
60
+ * const { Route } = RouteDecorators;
61
+ *
62
+ * @Route("/admin")
63
+ * export class AdminRoute extends BaseAdminRoute {}
64
+ * ```
49
65
  *
50
66
  * @author Jean-Philippe Steinmetz
51
67
  */
52
- let AdminRoute = class AdminRoute {
53
- /**
54
- * Constructs a new `ReleaseNotesRoute` object with the specified defaults.
55
- *
56
- * @param releaseNotes The ReleaseNotes specification object to serve.
57
- */
58
- constructor(releaseNotes) {
68
+ let BaseAdminRoute = class BaseAdminRoute {
69
+ constructor() {
59
70
  /** A map of user uid's to active sockets. */
60
71
  this.activeSockets = new Map();
61
72
  this.trustedRoles = [];
62
- this.releaseNotes = releaseNotes;
63
73
  }
64
74
  async init() {
75
+ if (this.cacheClient) {
76
+ this.logger.info("Cache is enabled and ready.");
77
+ }
78
+ else {
79
+ this.logger.warn("Cache is disabled.");
80
+ }
65
81
  if (this.cacheConnConfig) {
66
82
  const adminChannel = this.serviceName || "service_admin";
67
83
  this.redisClient = new Redis(this.cacheConnConfig.url, this.cacheConnConfig.options);
@@ -79,12 +95,13 @@ let AdminRoute = class AdminRoute {
79
95
  const channelName = this.serviceName + "-logs";
80
96
  this.logger.add(new RedisTransport({
81
97
  channelName,
82
- redis: new Redis(this.logsConnConfig.url, this.logsConnConfig.options)
98
+ redis: new Redis(this.logsConnConfig.url, this.logsConnConfig.options),
83
99
  }));
84
100
  }
85
101
  else {
86
102
  this.logger.warn("Could not initialize `/admin/logs` route. The `logs` datastore is not not configured.");
87
103
  }
104
+ // Discover the release notes file and load it (if available)
88
105
  }
89
106
  async clearCache(user) {
90
107
  if (!user || !UserUtils.hasRoles(user, this.trustedRoles)) {
@@ -167,7 +184,7 @@ let AdminRoute = class AdminRoute {
167
184
  this.activeSockets.set(user.uid, socks);
168
185
  }
169
186
  }
170
- get(user) {
187
+ getReleaseNotes(user) {
171
188
  if (user && user.uid && UserUtils.hasRoles(user, this.trustedRoles)) {
172
189
  return this.releaseNotes;
173
190
  }
@@ -187,33 +204,33 @@ let AdminRoute = class AdminRoute {
187
204
  __decorate([
188
205
  RedisConnection("cache"),
189
206
  __metadata("design:type", Redis)
190
- ], AdminRoute.prototype, "cacheClient", void 0);
207
+ ], BaseAdminRoute.prototype, "cacheClient", void 0);
191
208
  __decorate([
192
209
  Config("datastores:cache", null),
193
210
  __metadata("design:type", Object)
194
- ], AdminRoute.prototype, "cacheConnConfig", void 0);
211
+ ], BaseAdminRoute.prototype, "cacheConnConfig", void 0);
195
212
  __decorate([
196
213
  Logger,
197
214
  __metadata("design:type", Object)
198
- ], AdminRoute.prototype, "logger", void 0);
215
+ ], BaseAdminRoute.prototype, "logger", void 0);
199
216
  __decorate([
200
217
  Config("datastores:logs", null),
201
218
  __metadata("design:type", Object)
202
- ], AdminRoute.prototype, "logsConnConfig", void 0);
219
+ ], BaseAdminRoute.prototype, "logsConnConfig", void 0);
203
220
  __decorate([
204
221
  Config("service_name"),
205
222
  __metadata("design:type", String)
206
- ], AdminRoute.prototype, "serviceName", void 0);
223
+ ], BaseAdminRoute.prototype, "serviceName", void 0);
207
224
  __decorate([
208
225
  Config("trusted_roles"),
209
226
  __metadata("design:type", Array)
210
- ], AdminRoute.prototype, "trustedRoles", void 0);
227
+ ], BaseAdminRoute.prototype, "trustedRoles", void 0);
211
228
  __decorate([
212
229
  Init,
213
230
  __metadata("design:type", Function),
214
231
  __metadata("design:paramtypes", []),
215
232
  __metadata("design:returntype", Promise)
216
- ], AdminRoute.prototype, "init", null);
233
+ ], BaseAdminRoute.prototype, "init", null);
217
234
  __decorate([
218
235
  Summary("{{serviceName}} flush second-level cache"),
219
236
  Description("Flushes the second-level cache so that subsequent requests will pull directly from the database."),
@@ -224,7 +241,7 @@ __decorate([
224
241
  __metadata("design:type", Function),
225
242
  __metadata("design:paramtypes", [Object]),
226
243
  __metadata("design:returntype", Promise)
227
- ], AdminRoute.prototype, "clearCache", null);
244
+ ], BaseAdminRoute.prototype, "clearCache", null);
228
245
  __decorate([
229
246
  Summary("{{serviceName}} websocket to view live logs"),
230
247
  Description("Establishes a connection to the live log socket."),
@@ -235,7 +252,7 @@ __decorate([
235
252
  __metadata("design:type", Function),
236
253
  __metadata("design:paramtypes", [Function, Object]),
237
254
  __metadata("design:returntype", Promise)
238
- ], AdminRoute.prototype, "logs", null);
255
+ ], BaseAdminRoute.prototype, "logs", null);
239
256
  __decorate([
240
257
  Summary("{{serviceName}} release notes"),
241
258
  Description("Returns the release notes file for the service."),
@@ -246,8 +263,8 @@ __decorate([
246
263
  __param(0, User),
247
264
  __metadata("design:type", Function),
248
265
  __metadata("design:paramtypes", [Object]),
249
- __metadata("design:returntype", String)
250
- ], AdminRoute.prototype, "get", null);
266
+ __metadata("design:returntype", Object)
267
+ ], BaseAdminRoute.prototype, "getReleaseNotes", null);
251
268
  __decorate([
252
269
  Summary("{{serviceName}} Restart"),
253
270
  Description("Immediately restarts the service."),
@@ -258,11 +275,9 @@ __decorate([
258
275
  __metadata("design:type", Function),
259
276
  __metadata("design:paramtypes", [Object]),
260
277
  __metadata("design:returntype", void 0)
261
- ], AdminRoute.prototype, "restart", null);
262
- AdminRoute = __decorate([
263
- Summary("Admin routes supporting cache-clearing, restarting, logs and release notes"),
264
- Route("/admin"),
265
- __metadata("design:paramtypes", [String])
266
- ], AdminRoute);
267
- export { AdminRoute };
268
- //# sourceMappingURL=AdminRoute.js.map
278
+ ], BaseAdminRoute.prototype, "restart", null);
279
+ BaseAdminRoute = __decorate([
280
+ Summary("Admin routes supporting cache-clearing, restarting, logs and release notes")
281
+ ], BaseAdminRoute);
282
+ export { BaseAdminRoute };
283
+ //# sourceMappingURL=BaseAdminRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseAdminRoute.js","sourceRoot":"","sources":["../../../src/routes/BaseAdminRoute.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+EAA+E;AAC/E,kDAAkD;AAClD,+EAA+E;AAC/E,OAAO,EAAE,QAAQ,EAAW,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,KAAK,EAAc,MAAM,SAAS,CAAC;AAC5C,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC9D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,SAAS;IAIzC,YAAY,IAAS;QACjB,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IAC5B,CAAC;IAEM,KAAK;QACR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ACA,WAAA,MAAM,CAAA;IAA4B,WAAA,IAAI,CAAA;;;;0CA4DxD;AAQM;IANN,OAAO,CAAC,+BAA+B,CAAC;IACxC,WAAW,CAAC,iDAAiD,CAAC;IAC9D,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;IACb,GAAG,CAAC,gBAAgB,CAAC;IACrB,WAAW,CAAC,YAAY,CAAC;IACzB,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;IACM,WAAA,IAAI,CAAA;;;;qDAM3B;AAOM;IALN,OAAO,CAAC,yBAAyB,CAAC;IAClC,WAAW,CAAC,mCAAmC,CAAC;IAChD,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;IACb,GAAG,CAAC,UAAU,CAAC;IACf,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;IACA,WAAA,IAAI,CAAA;;;;6CAQnB;AA7LQ,cAAc;IAD1B,OAAO,CAAC,4EAA4E,CAAC;GACzE,cAAc,CA8L1B"}
@@ -15,18 +15,36 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
15
15
  ///////////////////////////////////////////////////////////////////////////////
16
16
  import * as prom from "prom-client";
17
17
  import { ApiError, UserUtils, ObjectDecorators } from "@rapidrest/core";
18
- import { Get, Param, Route, ContentType, User } from "../decorators/RouteDecorators.js";
18
+ import { Get, Param, ContentType, User } from "../decorators/RouteDecorators.js";
19
19
  import { Description, Returns, Summary } from "../decorators/DocDecorators.js";
20
20
  import { ApiErrorMessages, ApiErrors } from "../ApiErrors.js";
21
21
  const { Config } = ObjectDecorators;
22
22
  /**
23
- * Handles all REST API requests for the endpoint `/metrics'. This route handler produces Prometheus compatible metrics
24
- * for use with a Prometheus based server.
23
+ * The `BaseMetricsRoute` class provides a base set of endpoints for exposing Prometheus metrics.
24
+ *
25
+ * Exposed endpoints:
26
+ *
27
+ * | Name | HTTP Method | What it does |
28
+ * | --- | --- | --- |
29
+ * | `getMetrics` | `GET /<base_path>` | Returns all Prometheus metrics gathered by the system |
30
+ * | `getSingleMetric` | `GET /<base_path>/:metric` | Returns a single Prometheus metric with the given name |
25
31
  *
26
32
  * Services that wish to provide metrics to be exposed via this route can register them using the global registry
27
33
  * from the provided `prom-client` dependency. See the `prom-client` documentation for more details.
34
+ *
35
+ * !!Note!! that the `BaseMetricsRoute` is not automatically registered with a server by default. You must create
36
+ * your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { BaseMetricsRoute, RouteDecorators } from "@rapidrest/service-core";
41
+ * const { Route } = RouteDecorators;
42
+ *
43
+ * @Route("/metrics")
44
+ * export class MetricsRoute extends BaseMetricsRoute {}
45
+ * ```
28
46
  */
29
- let MetricsRoute = class MetricsRoute {
47
+ export class BaseMetricsRoute {
30
48
  constructor() {
31
49
  this.metricsConfig = {
32
50
  authRequired: true,
@@ -46,15 +64,15 @@ let MetricsRoute = class MetricsRoute {
46
64
  }
47
65
  return await this.registry.getSingleMetricAsString(metric);
48
66
  }
49
- };
67
+ }
50
68
  __decorate([
51
69
  Config("metrics", { authRequired: true }),
52
70
  __metadata("design:type", Object)
53
- ], MetricsRoute.prototype, "metricsConfig", void 0);
71
+ ], BaseMetricsRoute.prototype, "metricsConfig", void 0);
54
72
  __decorate([
55
73
  Config("trusted_roles"),
56
74
  __metadata("design:type", Array)
57
- ], MetricsRoute.prototype, "trustedRoles", void 0);
75
+ ], BaseMetricsRoute.prototype, "trustedRoles", void 0);
58
76
  __decorate([
59
77
  Summary("{{serviceName}} all Prometheus metrics"),
60
78
  Description("Returns all Prometheus metrics emitted by this service."),
@@ -65,7 +83,7 @@ __decorate([
65
83
  __metadata("design:type", Function),
66
84
  __metadata("design:paramtypes", [Object]),
67
85
  __metadata("design:returntype", Promise)
68
- ], MetricsRoute.prototype, "getMetrics", null);
86
+ ], BaseMetricsRoute.prototype, "getMetrics", null);
69
87
  __decorate([
70
88
  Summary("{{serviceName}} Prometheus metrics by name"),
71
89
  Description("Returns the Prometheus metric emitted by this service with the given name."),
@@ -77,10 +95,5 @@ __decorate([
77
95
  __metadata("design:type", Function),
78
96
  __metadata("design:paramtypes", [Object, Object]),
79
97
  __metadata("design:returntype", Promise)
80
- ], MetricsRoute.prototype, "getSingleMetric", null);
81
- MetricsRoute = __decorate([
82
- Route("/metrics"),
83
- __metadata("design:paramtypes", [])
84
- ], MetricsRoute);
85
- export { MetricsRoute };
86
- //# sourceMappingURL=MetricsRoute.js.map
98
+ ], BaseMetricsRoute.prototype, "getSingleMetric", null);
99
+ //# sourceMappingURL=BaseMetricsRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseMetricsRoute.js","sourceRoot":"","sources":["../../../src/routes/BaseMetricsRoute.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+EAA+E;AAC/E,kDAAkD;AAClD,+EAA+E;AAC/E,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAW,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAQ,GAAG,EAAE,KAAK,EAAS,WAAW,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC9D,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,gBAAgB;IAWzB;QATU,kBAAa,GAAG;YACtB,YAAY,EAAE,IAAI;SACrB,CAAC;QAKQ,iBAAY,GAAa,EAAE,CAAC;QAGlC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAClC,CAAC;IAOY,AAAN,KAAK,CAAC,UAAU,CAAO,IAAc;QACxC,IAAI,IAAI,CAAC,aAAa,CAAC,YAAY,IAAI,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,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;IACY,WAAA,KAAK,CAAC,QAAQ,CAAC,CAAA;IAAe,WAAA,IAAI,CAAA;;;;uDAK/D"}
@@ -13,7 +13,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
13
13
  import { ObjectDecorators } from "@rapidrest/core";
14
14
  import { OpenApiSpec } from "../OpenApiSpec.js";
15
15
  import { Description, Returns, Summary } from "../decorators/DocDecorators.js";
16
- import { Get, Route, ContentType } from "../decorators/RouteDecorators.js";
16
+ import { Get, ContentType } from "../decorators/RouteDecorators.js";
17
17
  const { Inject } = ObjectDecorators;
18
18
  /** Inline Swagger UI HTML page — loads swagger-ui-dist from CDN so there is no npm dependency. */
19
19
  function swaggerHtml(specUrl) {
@@ -39,15 +39,31 @@ function swaggerHtml(specUrl) {
39
39
  </html>`;
40
40
  }
41
41
  /**
42
- * The `OpenAPIRoute` provides default routes to expose the service's OpenAPI specification.
42
+ * The `BaseOpenAPIRoute` class provides a base set of endpoints exposing the server's OpenAPI specification.
43
43
  *
44
- * - `GET /` — Swagger UI HTML (loads swagger-ui-dist from CDN)
45
- * - `GET /openapi.json` — raw OpenAPI specification as JSON
46
- * - `GET /openapi.yaml` — raw OpenAPI specification as YAML
44
+ * Exposed endpoints:
45
+ *
46
+ * | Name | HTTP Method | What it does |
47
+ * | --- | --- | --- |
48
+ * | `getHTML` | `GET /<base_path>` | Swagger UI HTML (loads swagger-ui-dist from CDN) |
49
+ * | `getJSON` | `GET /<base_path>/json` | raw OpenAPI specification as JSON |
50
+ * | `getYAML` | `GET /<base_path>/yaml` | raw OpenAPI specification as YAML |
51
+ *
52
+ * !!Note!! that the `BaseAdminRoute` is not automatically registered with a server by default. You must create
53
+ * your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * import { BaseOpenAPIRoute, RouteDecorators } from "@rapidrest/service-core";
58
+ * const { Route } = RouteDecorators;
59
+ *
60
+ * @Route("/openapi")
61
+ * export class OpenAPIRoute extends BaseOpenAPIRoute {}
62
+ * ```
47
63
  *
48
64
  * @author Jean-Philippe Steinmetz
49
65
  */
50
- let OpenAPIRoute = class OpenAPIRoute {
66
+ export class BaseOpenAPIRoute {
51
67
  constructor() {
52
68
  /** The underlying OpenAPI specification. */
53
69
  this.apiSpec = new OpenApiSpec();
@@ -55,61 +71,44 @@ let OpenAPIRoute = class OpenAPIRoute {
55
71
  getHTML() {
56
72
  return swaggerHtml("/openapi.json");
57
73
  }
58
- getAPIDocs() {
59
- return swaggerHtml("/openapi.json");
60
- }
61
74
  getJSON() {
62
75
  return this.apiSpec.getSpec();
63
76
  }
64
77
  getYAML() {
65
78
  return this.apiSpec.getSpecAsYaml();
66
79
  }
67
- };
80
+ }
68
81
  __decorate([
69
82
  Inject(OpenApiSpec),
70
83
  __metadata("design:type", OpenApiSpec)
71
- ], OpenAPIRoute.prototype, "apiSpec", void 0);
72
- __decorate([
73
- Summary("{{serviceName}} OpenAPI, HTLM format"),
74
- Description("Returns the OpenAPI specification for the service in HTML format."),
75
- Get(),
76
- ContentType("text/html"),
77
- Returns([String]),
78
- __metadata("design:type", Function),
79
- __metadata("design:paramtypes", []),
80
- __metadata("design:returntype", String)
81
- ], OpenAPIRoute.prototype, "getHTML", null);
84
+ ], BaseOpenAPIRoute.prototype, "apiSpec", void 0);
82
85
  __decorate([
83
86
  Summary("{{serviceName}} API docs"),
84
87
  Description("Returns the OpenAPI specification for the service in HTML format."),
85
- Get("api-docs"),
88
+ Get(),
86
89
  ContentType("text/html"),
87
90
  Returns([String]),
88
91
  __metadata("design:type", Function),
89
92
  __metadata("design:paramtypes", []),
90
93
  __metadata("design:returntype", String)
91
- ], OpenAPIRoute.prototype, "getAPIDocs", null);
94
+ ], BaseOpenAPIRoute.prototype, "getHTML", null);
92
95
  __decorate([
93
96
  Summary("{{serviceName}} OpenAPI, JSON format"),
94
97
  Description("Returns the OpenAPI specification for the service in JSON format."),
95
- Get("openapi.json"),
98
+ Get("json"),
96
99
  Returns([String]),
97
100
  __metadata("design:type", Function),
98
101
  __metadata("design:paramtypes", []),
99
102
  __metadata("design:returntype", Object)
100
- ], OpenAPIRoute.prototype, "getJSON", null);
103
+ ], BaseOpenAPIRoute.prototype, "getJSON", null);
101
104
  __decorate([
102
105
  Summary("{{serviceName}} OpenAPI, YAML format"),
103
106
  Description("Returns the OpenAPI specification for the service in YAML format."),
104
- Get("openapi.yaml"),
107
+ Get("yaml"),
105
108
  ContentType("text/yaml"),
106
109
  Returns([String]),
107
110
  __metadata("design:type", Function),
108
111
  __metadata("design:paramtypes", []),
109
112
  __metadata("design:returntype", String)
110
- ], OpenAPIRoute.prototype, "getYAML", null);
111
- OpenAPIRoute = __decorate([
112
- Route("/")
113
- ], OpenAPIRoute);
114
- export { OpenAPIRoute };
115
- //# sourceMappingURL=OpenAPIRoute.js.map
113
+ ], BaseOpenAPIRoute.prototype, "getYAML", null);
114
+ //# sourceMappingURL=BaseOpenAPIRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseOpenAPIRoute.js","sourceRoot":"","sources":["../../../src/routes/BaseOpenAPIRoute.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+EAA+E;AAC/E,kDAAkD;AAClD,+EAA+E;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC;AAEpC,kGAAkG;AAClG,SAAS,WAAW,CAAC,OAAe;IAChC,OAAO;;;;;;;;;;;;cAYG,OAAO;;;;;;;QAOb,CAAC;AACT,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,gBAAgB;IAA7B;QACI,4CAA4C;QAElC,YAAO,GAAgB,IAAI,WAAW,EAAE,CAAC;IA2BvD,CAAC;IApBU,OAAO;QACV,OAAO,WAAW,CAAC,eAAe,CAAC,CAAC;IACxC,CAAC;IAMM,OAAO;QACV,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;IAOM,OAAO;QACV,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;IACxC,CAAC;CACJ;AA3Ba;IADT,MAAM,CAAC,WAAW,CAAC;8BACD,WAAW;iDAAqB;AAO5C;IALN,OAAO,CAAC,0BAA0B,CAAC;IACnC,WAAW,CAAC,mEAAmE,CAAC;IAChF,GAAG,EAAE;IACL,WAAW,CAAC,WAAW,CAAC;IACxB,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;;;;+CAGjB;AAMM;IAJN,OAAO,CAAC,sCAAsC,CAAC;IAC/C,WAAW,CAAC,mEAAmE,CAAC;IAChF,GAAG,CAAC,MAAM,CAAC;IACX,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;;;;+CAGjB;AAOM;IALN,OAAO,CAAC,sCAAsC,CAAC;IAC/C,WAAW,CAAC,mEAAmE,CAAC;IAChF,GAAG,CAAC,MAAM,CAAC;IACX,WAAW,CAAC,WAAW,CAAC;IACxB,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;;;;+CAGjB"}
@@ -0,0 +1,193 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { ApiError, ObjectDecorators } from "@rapidrest/core";
14
+ import { Auth, Param, Post, Socket, User, WebSocket } from "../decorators/RouteDecorators.js";
15
+ import { ACLUtils } from "../security/ACLUtils.js";
16
+ import ws from "ws";
17
+ import { Redis } from "ioredis";
18
+ import { Description, Summary } from "../decorators/DocDecorators.js";
19
+ import { ACLAction } from "../security/AccessControlList.js";
20
+ import { ApiErrorMessages, ApiErrors } from "../ApiErrors.js";
21
+ const { Config, Init, Inject, Logger } = ObjectDecorators;
22
+ /**
23
+ * The `BasePushRoute` class provides a base set of endpoints for implement client push notifications.
24
+ *
25
+ * Exposed endpoints:
26
+ *
27
+ * | Name | HTTP Method | What it does |
28
+ * | --- | --- | --- |
29
+ * | `connect` | `UPGRADE /<base_path>/connect` | Establishes a connection to the push notification system. |
30
+ * | `send` | `POST /<base_path>/:id` | Sends a push notification message to the channel with the given id |
31
+ *
32
+ * !!Note!! that the `BasePushRoute` is not automatically registered with a server by default. You must create
33
+ * your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { BasePushRoute, RouteDecorators } from "@rapidrest/service-core";
38
+ * const { Route } = RouteDecorators;
39
+ *
40
+ * @Route("/push")
41
+ * export class PushRoute extends BasePushRoute {}
42
+ * ```
43
+ *
44
+ * @author Jean-Philippe Steinmetz
45
+ */
46
+ export class BasePushRoute {
47
+ constructor() {
48
+ /** A map of active socket connections to users. */
49
+ this.activeSocks = new Map();
50
+ /** A map of active subscription uids to users. */
51
+ this.activeSubs = new Map();
52
+ }
53
+ init() {
54
+ if (this.redisConfig) {
55
+ this.redisPub = new Redis(this.redisConfig.url, this.redisConfig.options);
56
+ }
57
+ else {
58
+ this.logger.warn("Could not initialize the push notification publisher. The `events` datastore is not configured.");
59
+ }
60
+ }
61
+ async connect(sock, user) {
62
+ // Establish a new redis pub/sub client for this connection
63
+ const redis = new Redis(this.redisConfig.url, this.redisConfig.options);
64
+ const subs = this.activeSubs.get(user.uid) ?? [user.uid];
65
+ try {
66
+ await redis.subscribe(...subs);
67
+ this.logger.info(`User ${user.uid} successfully subscribed to push channels: ${subs}`);
68
+ sock.send(JSON.stringify({ id: 0, type: "SUBSCRIBED", success: true, data: subs }));
69
+ this.activeSubs.set(user.uid, subs);
70
+ }
71
+ catch (err) {
72
+ this.logger.error(`Failed to subscribe to push channels: user: ${user.uid}, subs: ${subs}`);
73
+ this.logger.debug(err);
74
+ }
75
+ // Track the socket so it doesn't get automatically cleaned up
76
+ const socks = this.activeSocks.get(user.uid) || [];
77
+ socks.push(sock);
78
+ this.activeSocks.set(user.uid, socks);
79
+ // Set up the outgoing message forwarding handler to the client
80
+ redis.on("message", (channel, message) => {
81
+ this.logger.debug(`Forwarding message to ${user.uid}`);
82
+ sock.send(message, (err) => {
83
+ if (err) {
84
+ this.logger.debug(`Failed to forward message to ${user.uid}`);
85
+ }
86
+ });
87
+ });
88
+ // Set up the incoming message handler from the client
89
+ sock.on("message", async (data, isBinary) => {
90
+ if (!isBinary) {
91
+ try {
92
+ // Decode the incoming message
93
+ const message = JSON.parse(data);
94
+ const origSubs = this.activeSubs.get(user.uid) ?? [user.uid];
95
+ if (message.type === "SUBSCRIBE") {
96
+ const subs = Array.isArray(message.data) ? message.data : [message.data];
97
+ const subd = [];
98
+ // Check that the user has permission for each requested channel
99
+ for (const channel of subs) {
100
+ if (await this.aclUtils?.hasPermission(user, channel, ACLAction.READ)) {
101
+ subd.push(channel);
102
+ }
103
+ }
104
+ // Subscribe to all approved channels
105
+ await redis.subscribe(...subd);
106
+ this.activeSubs.set(user.uid, origSubs.concat(subd));
107
+ sock.send(JSON.stringify({ id: message.id, type: "SUBSCRIBED", success: true, data: subd }));
108
+ }
109
+ if (message.type === "UNSUBSCRIBE") {
110
+ const subs = Array.isArray(message.data) ? message.data : [message.data];
111
+ await redis.unsubscribe(...subs);
112
+ for (const channel of subs) {
113
+ origSubs.splice(origSubs.indexOf(channel), 1);
114
+ }
115
+ this.activeSubs.set(user.uid, origSubs);
116
+ sock.send(JSON.stringify({ id: message.id, type: "UNSUBSCRIBED", success: true, data: subs }));
117
+ }
118
+ else {
119
+ this.logger.debug(`Received invalid message from user ${user.uid}.`);
120
+ }
121
+ }
122
+ catch (err) {
123
+ this.logger.debug(`Received invalid message from user ${user.uid}.`);
124
+ }
125
+ }
126
+ });
127
+ // Set up the close connection handler
128
+ sock.on("close", async (code, reason) => {
129
+ // Unsubscribe from all redis pub/sub channels
130
+ const subs = this.activeSubs.get(user.uid);
131
+ if (subs) {
132
+ await redis.unsubscribe(...subs);
133
+ }
134
+ // Disconnect the redis client
135
+ redis.disconnect();
136
+ // Remove the socket from our tracked list
137
+ const socks = this.activeSocks.get(user.uid) || [];
138
+ socks.splice(socks.indexOf(sock), 1);
139
+ this.activeSocks.set(user.uid, socks);
140
+ });
141
+ }
142
+ async send(id, msg, user) {
143
+ if (!(await this.aclUtils?.hasPermission(user, id, ACLAction.CREATE))) {
144
+ throw new ApiError(ApiErrors.AUTH_PERMISSION_FAILURE, 403, ApiErrorMessages.AUTH_PERMISSION_FAILURE);
145
+ }
146
+ if (!this.redisPub) {
147
+ this.logger.error(`Failed to send push message to channel ${id}. The \`events\` datastore is not configured.`);
148
+ throw new ApiError(ApiErrors.INTERNAL_ERROR, 500, ApiErrorMessages.INTERNAL_ERROR);
149
+ }
150
+ await this.redisPub.publish(id, JSON.stringify({ type: "MESSAGE", channel: id, data: msg }));
151
+ }
152
+ }
153
+ __decorate([
154
+ Inject(ACLUtils),
155
+ __metadata("design:type", ACLUtils)
156
+ ], BasePushRoute.prototype, "aclUtils", void 0);
157
+ __decorate([
158
+ Logger,
159
+ __metadata("design:type", Object)
160
+ ], BasePushRoute.prototype, "logger", void 0);
161
+ __decorate([
162
+ Config("datastores:events"),
163
+ __metadata("design:type", Object)
164
+ ], BasePushRoute.prototype, "redisConfig", void 0);
165
+ __decorate([
166
+ Init,
167
+ __metadata("design:type", Function),
168
+ __metadata("design:paramtypes", []),
169
+ __metadata("design:returntype", void 0)
170
+ ], BasePushRoute.prototype, "init", null);
171
+ __decorate([
172
+ Summary("Push connect"),
173
+ Description("Establishes a connection to the push notification system."),
174
+ Auth(["jwt"]),
175
+ WebSocket(),
176
+ __param(0, Socket),
177
+ __param(1, User),
178
+ __metadata("design:type", Function),
179
+ __metadata("design:paramtypes", [ws, Object]),
180
+ __metadata("design:returntype", Promise)
181
+ ], BasePushRoute.prototype, "connect", null);
182
+ __decorate([
183
+ Summary("Send push"),
184
+ Description("Sends a push notification message to the channel with the given id."),
185
+ Auth(["jwt"]),
186
+ Post("/:id"),
187
+ __param(0, Param("id")),
188
+ __param(2, User),
189
+ __metadata("design:type", Function),
190
+ __metadata("design:paramtypes", [String, Object, Object]),
191
+ __metadata("design:returntype", Promise)
192
+ ], BasePushRoute.prototype, "send", null);
193
+ //# sourceMappingURL=BasePushRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BasePushRoute.js","sourceRoot":"","sources":["../../../src/routes/BasePushRoute.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE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