@scpxl/nodejs-framework 1.0.13

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 (411) hide show
  1. package/README.md +195 -0
  2. package/dist/api-requester/api-requester.d.ts +11 -0
  3. package/dist/api-requester/api-requester.d.ts.map +1 -0
  4. package/dist/api-requester/api-requester.js +59 -0
  5. package/dist/api-requester/api-requester.js.map +7 -0
  6. package/dist/api-requester/index.d.ts +2 -0
  7. package/dist/api-requester/index.d.ts.map +1 -0
  8. package/dist/api-requester/index.js +5 -0
  9. package/dist/api-requester/index.js.map +7 -0
  10. package/dist/application/base-application.d.ts +110 -0
  11. package/dist/application/base-application.d.ts.map +1 -0
  12. package/dist/application/base-application.interface.d.ts +161 -0
  13. package/dist/application/base-application.interface.d.ts.map +1 -0
  14. package/dist/application/base-application.interface.js +1 -0
  15. package/dist/application/base-application.interface.js.map +7 -0
  16. package/dist/application/base-application.js +350 -0
  17. package/dist/application/base-application.js.map +7 -0
  18. package/dist/application/command-application.d.ts +18 -0
  19. package/dist/application/command-application.d.ts.map +1 -0
  20. package/dist/application/command-application.interface.d.ts +26 -0
  21. package/dist/application/command-application.interface.d.ts.map +1 -0
  22. package/dist/application/command-application.interface.js +1 -0
  23. package/dist/application/command-application.interface.js.map +7 -0
  24. package/dist/application/command-application.js +110 -0
  25. package/dist/application/command-application.js.map +7 -0
  26. package/dist/application/index.d.ts +5 -0
  27. package/dist/application/index.d.ts.map +1 -0
  28. package/dist/application/index.js +7 -0
  29. package/dist/application/index.js.map +7 -0
  30. package/dist/application/web-application.d.ts +43 -0
  31. package/dist/application/web-application.d.ts.map +1 -0
  32. package/dist/application/web-application.interface.d.ts +21 -0
  33. package/dist/application/web-application.interface.d.ts.map +1 -0
  34. package/dist/application/web-application.interface.js +1 -0
  35. package/dist/application/web-application.interface.js.map +7 -0
  36. package/dist/application/web-application.js +176 -0
  37. package/dist/application/web-application.js.map +7 -0
  38. package/dist/auth/index.d.ts +2 -0
  39. package/dist/auth/index.d.ts.map +1 -0
  40. package/dist/auth/index.js +5 -0
  41. package/dist/auth/index.js.map +7 -0
  42. package/dist/auth/jwt.d.ts +25 -0
  43. package/dist/auth/jwt.d.ts.map +1 -0
  44. package/dist/auth/jwt.js +51 -0
  45. package/dist/auth/jwt.js.map +7 -0
  46. package/dist/cache/index.d.ts +2 -0
  47. package/dist/cache/index.d.ts.map +1 -0
  48. package/dist/cache/index.js +5 -0
  49. package/dist/cache/index.js.map +7 -0
  50. package/dist/cache/manager.d.ts +26 -0
  51. package/dist/cache/manager.d.ts.map +1 -0
  52. package/dist/cache/manager.js +54 -0
  53. package/dist/cache/manager.js.map +7 -0
  54. package/dist/cluster/cluster-manager.d.ts +15 -0
  55. package/dist/cluster/cluster-manager.d.ts.map +1 -0
  56. package/dist/cluster/cluster-manager.interface.d.ts +23 -0
  57. package/dist/cluster/cluster-manager.interface.d.ts.map +1 -0
  58. package/dist/cluster/cluster-manager.interface.js +1 -0
  59. package/dist/cluster/cluster-manager.interface.js.map +7 -0
  60. package/dist/cluster/cluster-manager.js +106 -0
  61. package/dist/cluster/cluster-manager.js.map +7 -0
  62. package/dist/cluster/index.d.ts +2 -0
  63. package/dist/cluster/index.d.ts.map +1 -0
  64. package/dist/cluster/index.js +13 -0
  65. package/dist/cluster/index.js.map +7 -0
  66. package/dist/command/command-manager.d.ts +19 -0
  67. package/dist/command/command-manager.d.ts.map +1 -0
  68. package/dist/command/command-manager.js +42 -0
  69. package/dist/command/command-manager.js.map +7 -0
  70. package/dist/command/command.d.ts +27 -0
  71. package/dist/command/command.d.ts.map +1 -0
  72. package/dist/command/command.interface.d.ts +11 -0
  73. package/dist/command/command.interface.d.ts.map +1 -0
  74. package/dist/command/command.interface.js +1 -0
  75. package/dist/command/command.interface.js.map +7 -0
  76. package/dist/command/command.js +37 -0
  77. package/dist/command/command.js.map +7 -0
  78. package/dist/command/index.d.ts +3 -0
  79. package/dist/command/index.d.ts.map +1 -0
  80. package/dist/command/index.js +7 -0
  81. package/dist/command/index.js.map +7 -0
  82. package/dist/database/dynamic-entity-form-decorators.d.ts +31 -0
  83. package/dist/database/dynamic-entity-form-decorators.d.ts.map +1 -0
  84. package/dist/database/dynamic-entity-form-decorators.js +62 -0
  85. package/dist/database/dynamic-entity-form-decorators.js.map +7 -0
  86. package/dist/database/dynamic-entity.d.ts +15 -0
  87. package/dist/database/dynamic-entity.d.ts.map +1 -0
  88. package/dist/database/dynamic-entity.js +42 -0
  89. package/dist/database/dynamic-entity.js.map +7 -0
  90. package/dist/database/index.d.ts +5 -0
  91. package/dist/database/index.d.ts.map +1 -0
  92. package/dist/database/index.js +12 -0
  93. package/dist/database/index.js.map +7 -0
  94. package/dist/database/instance.d.ts +36 -0
  95. package/dist/database/instance.d.ts.map +1 -0
  96. package/dist/database/instance.interface.d.ts +5 -0
  97. package/dist/database/instance.interface.d.ts.map +1 -0
  98. package/dist/database/instance.interface.js +1 -0
  99. package/dist/database/instance.interface.js.map +7 -0
  100. package/dist/database/instance.js +57 -0
  101. package/dist/database/instance.js.map +7 -0
  102. package/dist/database/manager.d.ts +27 -0
  103. package/dist/database/manager.d.ts.map +1 -0
  104. package/dist/database/manager.interface.d.ts +18 -0
  105. package/dist/database/manager.interface.d.ts.map +1 -0
  106. package/dist/database/manager.interface.js +1 -0
  107. package/dist/database/manager.interface.js.map +7 -0
  108. package/dist/database/manager.js +49 -0
  109. package/dist/database/manager.js.map +7 -0
  110. package/dist/event/controller/base.d.ts +23 -0
  111. package/dist/event/controller/base.d.ts.map +1 -0
  112. package/dist/event/controller/base.interface.d.ts +11 -0
  113. package/dist/event/controller/base.interface.d.ts.map +1 -0
  114. package/dist/event/controller/base.interface.js +1 -0
  115. package/dist/event/controller/base.interface.js.map +7 -0
  116. package/dist/event/controller/base.js +51 -0
  117. package/dist/event/controller/base.js.map +7 -0
  118. package/dist/event/index.d.ts +5 -0
  119. package/dist/event/index.d.ts.map +1 -0
  120. package/dist/event/index.js +9 -0
  121. package/dist/event/index.js.map +7 -0
  122. package/dist/event/manager.d.ts +21 -0
  123. package/dist/event/manager.d.ts.map +1 -0
  124. package/dist/event/manager.interface.d.ts +134 -0
  125. package/dist/event/manager.interface.d.ts.map +1 -0
  126. package/dist/event/manager.interface.js +1 -0
  127. package/dist/event/manager.interface.js.map +7 -0
  128. package/dist/event/manager.js +134 -0
  129. package/dist/event/manager.js.map +7 -0
  130. package/dist/index.d.ts +18 -0
  131. package/dist/index.d.ts.map +1 -0
  132. package/dist/index.js +23 -0
  133. package/dist/index.js.map +7 -0
  134. package/dist/logger/index.d.ts +2 -0
  135. package/dist/logger/index.d.ts.map +1 -0
  136. package/dist/logger/index.js +5 -0
  137. package/dist/logger/index.js.map +7 -0
  138. package/dist/logger/logger.d.ts +51 -0
  139. package/dist/logger/logger.d.ts.map +1 -0
  140. package/dist/logger/logger.interface.d.ts +2 -0
  141. package/dist/logger/logger.interface.d.ts.map +1 -0
  142. package/dist/logger/logger.interface.js +1 -0
  143. package/dist/logger/logger.interface.js.map +7 -0
  144. package/dist/logger/logger.js +168 -0
  145. package/dist/logger/logger.js.map +7 -0
  146. package/dist/performance/cache-performance.d.ts +58 -0
  147. package/dist/performance/cache-performance.d.ts.map +1 -0
  148. package/dist/performance/cache-performance.js +199 -0
  149. package/dist/performance/cache-performance.js.map +7 -0
  150. package/dist/performance/database-performance.d.ts +40 -0
  151. package/dist/performance/database-performance.d.ts.map +1 -0
  152. package/dist/performance/database-performance.js +132 -0
  153. package/dist/performance/database-performance.js.map +7 -0
  154. package/dist/performance/index.d.ts +7 -0
  155. package/dist/performance/index.d.ts.map +1 -0
  156. package/dist/performance/index.js +7 -0
  157. package/dist/performance/index.js.map +7 -0
  158. package/dist/performance/performance-monitor.d.ts +68 -0
  159. package/dist/performance/performance-monitor.d.ts.map +1 -0
  160. package/dist/performance/performance-monitor.js +270 -0
  161. package/dist/performance/performance-monitor.js.map +7 -0
  162. package/dist/performance/queue-performance.d.ts +46 -0
  163. package/dist/performance/queue-performance.d.ts.map +1 -0
  164. package/dist/performance/queue-performance.js +144 -0
  165. package/dist/performance/queue-performance.js.map +7 -0
  166. package/dist/performance/webserver-performance.d.ts +69 -0
  167. package/dist/performance/webserver-performance.d.ts.map +1 -0
  168. package/dist/performance/webserver-performance.js +164 -0
  169. package/dist/performance/webserver-performance.js.map +7 -0
  170. package/dist/performance/websocket-performance.d.ts +44 -0
  171. package/dist/performance/websocket-performance.d.ts.map +1 -0
  172. package/dist/performance/websocket-performance.js +139 -0
  173. package/dist/performance/websocket-performance.js.map +7 -0
  174. package/dist/queue/index.d.ts +6 -0
  175. package/dist/queue/index.d.ts.map +1 -0
  176. package/dist/queue/index.interface.d.ts +10 -0
  177. package/dist/queue/index.interface.d.ts.map +1 -0
  178. package/dist/queue/index.interface.js +1 -0
  179. package/dist/queue/index.interface.js.map +7 -0
  180. package/dist/queue/index.js +7 -0
  181. package/dist/queue/index.js.map +7 -0
  182. package/dist/queue/job.interface.d.ts +42 -0
  183. package/dist/queue/job.interface.d.ts.map +1 -0
  184. package/dist/queue/job.interface.js +1 -0
  185. package/dist/queue/job.interface.js.map +7 -0
  186. package/dist/queue/manager.d.ts +36 -0
  187. package/dist/queue/manager.d.ts.map +1 -0
  188. package/dist/queue/manager.interface.d.ts +18 -0
  189. package/dist/queue/manager.interface.d.ts.map +1 -0
  190. package/dist/queue/manager.interface.js +1 -0
  191. package/dist/queue/manager.interface.js.map +7 -0
  192. package/dist/queue/manager.js +244 -0
  193. package/dist/queue/manager.js.map +7 -0
  194. package/dist/queue/processor/base.d.ts +28 -0
  195. package/dist/queue/processor/base.d.ts.map +1 -0
  196. package/dist/queue/processor/base.js +46 -0
  197. package/dist/queue/processor/base.js.map +7 -0
  198. package/dist/queue/processor/processor.interface.d.ts +15 -0
  199. package/dist/queue/processor/processor.interface.d.ts.map +1 -0
  200. package/dist/queue/processor/processor.interface.js +1 -0
  201. package/dist/queue/processor/processor.interface.js.map +7 -0
  202. package/dist/queue/worker.d.ts +14 -0
  203. package/dist/queue/worker.d.ts.map +1 -0
  204. package/dist/queue/worker.interface.d.ts +13 -0
  205. package/dist/queue/worker.interface.d.ts.map +1 -0
  206. package/dist/queue/worker.interface.js +1 -0
  207. package/dist/queue/worker.interface.js.map +7 -0
  208. package/dist/queue/worker.js +72 -0
  209. package/dist/queue/worker.js.map +7 -0
  210. package/dist/redis/index.d.ts +3 -0
  211. package/dist/redis/index.d.ts.map +1 -0
  212. package/dist/redis/index.js +7 -0
  213. package/dist/redis/index.js.map +7 -0
  214. package/dist/redis/instance.d.ts +32 -0
  215. package/dist/redis/instance.d.ts.map +1 -0
  216. package/dist/redis/instance.interface.d.ts +9 -0
  217. package/dist/redis/instance.interface.d.ts.map +1 -0
  218. package/dist/redis/instance.interface.js +1 -0
  219. package/dist/redis/instance.interface.js.map +7 -0
  220. package/dist/redis/instance.js +92 -0
  221. package/dist/redis/instance.js.map +7 -0
  222. package/dist/redis/manager.d.ts +15 -0
  223. package/dist/redis/manager.d.ts.map +1 -0
  224. package/dist/redis/manager.interface.d.ts +8 -0
  225. package/dist/redis/manager.interface.d.ts.map +1 -0
  226. package/dist/redis/manager.interface.js +1 -0
  227. package/dist/redis/manager.interface.js.map +7 -0
  228. package/dist/redis/manager.js +65 -0
  229. package/dist/redis/manager.js.map +7 -0
  230. package/dist/services/aws/index.d.ts +2 -0
  231. package/dist/services/aws/index.d.ts.map +1 -0
  232. package/dist/services/aws/index.js +5 -0
  233. package/dist/services/aws/index.js.map +7 -0
  234. package/dist/services/aws/s3.d.ts +54 -0
  235. package/dist/services/aws/s3.d.ts.map +1 -0
  236. package/dist/services/aws/s3.interface.d.ts +14 -0
  237. package/dist/services/aws/s3.interface.d.ts.map +1 -0
  238. package/dist/services/aws/s3.interface.js +1 -0
  239. package/dist/services/aws/s3.interface.js.map +7 -0
  240. package/dist/services/aws/s3.js +236 -0
  241. package/dist/services/aws/s3.js.map +7 -0
  242. package/dist/services/index.d.ts +2 -0
  243. package/dist/services/index.d.ts.map +1 -0
  244. package/dist/services/index.js +2 -0
  245. package/dist/services/index.js.map +7 -0
  246. package/dist/util/file.d.ts +45 -0
  247. package/dist/util/file.d.ts.map +1 -0
  248. package/dist/util/file.js +105 -0
  249. package/dist/util/file.js.map +7 -0
  250. package/dist/util/helper.d.ts +37 -0
  251. package/dist/util/helper.d.ts.map +1 -0
  252. package/dist/util/helper.js +73 -0
  253. package/dist/util/helper.js.map +7 -0
  254. package/dist/util/image.d.ts +12 -0
  255. package/dist/util/image.d.ts.map +1 -0
  256. package/dist/util/image.js +35 -0
  257. package/dist/util/image.js.map +7 -0
  258. package/dist/util/index.d.ts +10 -0
  259. package/dist/util/index.d.ts.map +1 -0
  260. package/dist/util/index.js +21 -0
  261. package/dist/util/index.js.map +7 -0
  262. package/dist/util/loader.d.ts +19 -0
  263. package/dist/util/loader.d.ts.map +1 -0
  264. package/dist/util/loader.js +84 -0
  265. package/dist/util/loader.js.map +7 -0
  266. package/dist/util/num.d.ts +13 -0
  267. package/dist/util/num.d.ts.map +1 -0
  268. package/dist/util/num.js +16 -0
  269. package/dist/util/num.js.map +7 -0
  270. package/dist/util/os.d.ts +6 -0
  271. package/dist/util/os.d.ts.map +1 -0
  272. package/dist/util/os.js +32 -0
  273. package/dist/util/os.js.map +7 -0
  274. package/dist/util/str.d.ts +39 -0
  275. package/dist/util/str.d.ts.map +1 -0
  276. package/dist/util/str.js +34 -0
  277. package/dist/util/str.js.map +7 -0
  278. package/dist/util/time.d.ts +13 -0
  279. package/dist/util/time.d.ts.map +1 -0
  280. package/dist/util/time.interface.d.ts +12 -0
  281. package/dist/util/time.interface.d.ts.map +1 -0
  282. package/dist/util/time.interface.js +1 -0
  283. package/dist/util/time.interface.js.map +7 -0
  284. package/dist/util/time.js +90 -0
  285. package/dist/util/time.js.map +7 -0
  286. package/dist/util/url.d.ts +7 -0
  287. package/dist/util/url.d.ts.map +1 -0
  288. package/dist/util/url.js +12 -0
  289. package/dist/util/url.js.map +7 -0
  290. package/dist/webserver/controller/auth-middleware.d.ts +21 -0
  291. package/dist/webserver/controller/auth-middleware.d.ts.map +1 -0
  292. package/dist/webserver/controller/auth-middleware.js +33 -0
  293. package/dist/webserver/controller/auth-middleware.js.map +7 -0
  294. package/dist/webserver/controller/base.d.ts +39 -0
  295. package/dist/webserver/controller/base.d.ts.map +1 -0
  296. package/dist/webserver/controller/base.interface.d.ts +45 -0
  297. package/dist/webserver/controller/base.interface.d.ts.map +1 -0
  298. package/dist/webserver/controller/base.interface.js +1 -0
  299. package/dist/webserver/controller/base.interface.js.map +7 -0
  300. package/dist/webserver/controller/base.js +188 -0
  301. package/dist/webserver/controller/base.js.map +7 -0
  302. package/dist/webserver/controller/entity.d.ts +94 -0
  303. package/dist/webserver/controller/entity.d.ts.map +1 -0
  304. package/dist/webserver/controller/entity.js +361 -0
  305. package/dist/webserver/controller/entity.js.map +7 -0
  306. package/dist/webserver/controller/example-auth.d.ts +12 -0
  307. package/dist/webserver/controller/example-auth.d.ts.map +1 -0
  308. package/dist/webserver/controller/example-auth.js +53 -0
  309. package/dist/webserver/controller/example-auth.js.map +7 -0
  310. package/dist/webserver/controller/health.d.ts +8 -0
  311. package/dist/webserver/controller/health.d.ts.map +1 -0
  312. package/dist/webserver/controller/health.js +50 -0
  313. package/dist/webserver/controller/health.js.map +7 -0
  314. package/dist/webserver/index.d.ts +12 -0
  315. package/dist/webserver/index.d.ts.map +1 -0
  316. package/dist/webserver/index.js +19 -0
  317. package/dist/webserver/index.js.map +7 -0
  318. package/dist/webserver/util.d.ts +10 -0
  319. package/dist/webserver/util.d.ts.map +1 -0
  320. package/dist/webserver/util.js +63 -0
  321. package/dist/webserver/util.js.map +7 -0
  322. package/dist/webserver/webserver.d.ts +65 -0
  323. package/dist/webserver/webserver.d.ts.map +1 -0
  324. package/dist/webserver/webserver.interface.d.ts +118 -0
  325. package/dist/webserver/webserver.interface.d.ts.map +1 -0
  326. package/dist/webserver/webserver.interface.js +9 -0
  327. package/dist/webserver/webserver.interface.js.map +7 -0
  328. package/dist/webserver/webserver.js +347 -0
  329. package/dist/webserver/webserver.js.map +7 -0
  330. package/dist/websocket/controller/client/base.d.ts +12 -0
  331. package/dist/websocket/controller/client/base.d.ts.map +1 -0
  332. package/dist/websocket/controller/client/base.interface.d.ts +12 -0
  333. package/dist/websocket/controller/client/base.interface.d.ts.map +1 -0
  334. package/dist/websocket/controller/client/base.interface.js +1 -0
  335. package/dist/websocket/controller/client/base.interface.js.map +7 -0
  336. package/dist/websocket/controller/client/base.js +26 -0
  337. package/dist/websocket/controller/client/base.js.map +7 -0
  338. package/dist/websocket/controller/server/base.d.ts +13 -0
  339. package/dist/websocket/controller/server/base.d.ts.map +1 -0
  340. package/dist/websocket/controller/server/base.interface.d.ts +13 -0
  341. package/dist/websocket/controller/server/base.interface.d.ts.map +1 -0
  342. package/dist/websocket/controller/server/base.interface.js +1 -0
  343. package/dist/websocket/controller/server/base.interface.js.map +7 -0
  344. package/dist/websocket/controller/server/base.js +26 -0
  345. package/dist/websocket/controller/server/base.js.map +7 -0
  346. package/dist/websocket/controllers/client/system.d.ts +6 -0
  347. package/dist/websocket/controllers/client/system.d.ts.map +1 -0
  348. package/dist/websocket/controllers/client/system.js +14 -0
  349. package/dist/websocket/controllers/client/system.js.map +7 -0
  350. package/dist/websocket/controllers/server/system.d.ts +7 -0
  351. package/dist/websocket/controllers/server/system.d.ts.map +1 -0
  352. package/dist/websocket/controllers/server/system.js +87 -0
  353. package/dist/websocket/controllers/server/system.js.map +7 -0
  354. package/dist/websocket/index.d.ts +7 -0
  355. package/dist/websocket/index.d.ts.map +1 -0
  356. package/dist/websocket/index.js +11 -0
  357. package/dist/websocket/index.js.map +7 -0
  358. package/dist/websocket/routes/client/system.d.ts +3 -0
  359. package/dist/websocket/routes/client/system.d.ts.map +1 -0
  360. package/dist/websocket/routes/client/system.js +11 -0
  361. package/dist/websocket/routes/client/system.js.map +7 -0
  362. package/dist/websocket/routes/server/system.d.ts +3 -0
  363. package/dist/websocket/routes/server/system.d.ts.map +1 -0
  364. package/dist/websocket/routes/server/system.js +16 -0
  365. package/dist/websocket/routes/server/system.js.map +7 -0
  366. package/dist/websocket/utils.d.ts +9 -0
  367. package/dist/websocket/utils.d.ts.map +1 -0
  368. package/dist/websocket/utils.js +39 -0
  369. package/dist/websocket/utils.js.map +7 -0
  370. package/dist/websocket/websocket-base.d.ts +15 -0
  371. package/dist/websocket/websocket-base.d.ts.map +1 -0
  372. package/dist/websocket/websocket-base.js +104 -0
  373. package/dist/websocket/websocket-base.js.map +7 -0
  374. package/dist/websocket/websocket-client-manager.d.ts +53 -0
  375. package/dist/websocket/websocket-client-manager.d.ts.map +1 -0
  376. package/dist/websocket/websocket-client-manager.interface.d.ts +8 -0
  377. package/dist/websocket/websocket-client-manager.interface.d.ts.map +1 -0
  378. package/dist/websocket/websocket-client-manager.interface.js +1 -0
  379. package/dist/websocket/websocket-client-manager.interface.js.map +7 -0
  380. package/dist/websocket/websocket-client-manager.js +225 -0
  381. package/dist/websocket/websocket-client-manager.js.map +7 -0
  382. package/dist/websocket/websocket-client.d.ts +35 -0
  383. package/dist/websocket/websocket-client.d.ts.map +1 -0
  384. package/dist/websocket/websocket-client.interface.d.ts +14 -0
  385. package/dist/websocket/websocket-client.interface.d.ts.map +1 -0
  386. package/dist/websocket/websocket-client.interface.js +1 -0
  387. package/dist/websocket/websocket-client.interface.js.map +7 -0
  388. package/dist/websocket/websocket-client.js +158 -0
  389. package/dist/websocket/websocket-client.js.map +7 -0
  390. package/dist/websocket/websocket-room-manager.d.ts +32 -0
  391. package/dist/websocket/websocket-room-manager.d.ts.map +1 -0
  392. package/dist/websocket/websocket-room-manager.js +130 -0
  393. package/dist/websocket/websocket-room-manager.js.map +7 -0
  394. package/dist/websocket/websocket-server.d.ts +92 -0
  395. package/dist/websocket/websocket-server.d.ts.map +1 -0
  396. package/dist/websocket/websocket-server.interface.d.ts +16 -0
  397. package/dist/websocket/websocket-server.interface.d.ts.map +1 -0
  398. package/dist/websocket/websocket-server.interface.js +1 -0
  399. package/dist/websocket/websocket-server.interface.js.map +7 -0
  400. package/dist/websocket/websocket-server.js +686 -0
  401. package/dist/websocket/websocket-server.js.map +7 -0
  402. package/dist/websocket/websocket-service.d.ts +44 -0
  403. package/dist/websocket/websocket-service.d.ts.map +1 -0
  404. package/dist/websocket/websocket-service.js +99 -0
  405. package/dist/websocket/websocket-service.js.map +7 -0
  406. package/dist/websocket/websocket.interface.d.ts +119 -0
  407. package/dist/websocket/websocket.interface.d.ts.map +1 -0
  408. package/dist/websocket/websocket.interface.js +18 -0
  409. package/dist/websocket/websocket.interface.js.map +7 -0
  410. package/package.json +159 -0
  411. package/pxl.js +4 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/webserver/controller/base.ts"],
4
+ "sourcesContent": ["import { StatusCodes } from 'http-status-codes';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\nimport type { DatabaseInstance } from '../../database/index.js';\nimport type { RedisInstance } from '../../redis/index.js';\nimport type { QueueManager } from '../../queue/index.js';\nimport type { ApiError, ApiResponse, WebServerBaseControllerConstructorParams } from './base.interface.js';\nimport { Logger } from '../../logger/index.js';\nimport type { ApplicationConfig } from '../../application/base-application.interface.js';\nimport type EventManager from '../../event/manager.js';\nimport cluster from 'cluster';\nimport type { WebServerOptions } from '../webserver.interface.js';\nimport Jwt from '../../auth/jwt.js';\n// import { env } from '../../env';\n\nexport interface AuthenticatedUser {\n userId: number;\n payload: any;\n}\n\nexport default abstract class BaseController {\n protected workerId: number | undefined;\n\n protected applicationConfig: ApplicationConfig;\n protected webServerOptions: WebServerOptions;\n\n protected redisInstance: RedisInstance;\n protected queueManager: QueueManager;\n protected eventManager: EventManager;\n protected databaseInstance: DatabaseInstance;\n\n constructor({\n applicationConfig,\n webServerOptions,\n redisInstance,\n queueManager,\n eventManager,\n databaseInstance,\n }: WebServerBaseControllerConstructorParams) {\n this.workerId = cluster.worker?.id;\n\n this.applicationConfig = applicationConfig;\n this.webServerOptions = webServerOptions;\n\n this.redisInstance = redisInstance;\n this.queueManager = queueManager;\n this.eventManager = eventManager;\n this.databaseInstance = databaseInstance;\n }\n\n protected sendSuccessResponse<T = any>({\n reply,\n data,\n statusCode = StatusCodes.OK,\n meta,\n }: {\n reply: FastifyReply;\n data: T;\n statusCode?: StatusCodes;\n meta?: ApiResponse<T>['meta'];\n }) {\n const response: ApiResponse<T> = {\n data,\n meta: {\n timestamp: new Date().toISOString(),\n requestId: reply.request.id || 'unknown',\n ...meta,\n },\n };\n reply.status(statusCode).send(response);\n }\n\n protected sendNotFoundResponse(reply: FastifyReply, message: string = 'Resource not found') {\n const error: ApiError = {\n message,\n type: 'not_found',\n timestamp: new Date().toISOString(),\n requestId: reply.request.id || 'unknown',\n };\n const response: ApiResponse = { error };\n reply.status(StatusCodes.NOT_FOUND).send(response);\n }\n\n protected sendErrorResponse({\n reply,\n error,\n statusCode = StatusCodes.BAD_REQUEST,\n errorType,\n }: {\n reply: FastifyReply;\n error: unknown;\n statusCode?: StatusCodes;\n errorType?: ApiError['type'];\n }) {\n let publicErrorMessage: string;\n let errorDetails: any = undefined;\n\n if (this.webServerOptions.errors?.verbose === true) {\n if (error instanceof Error) {\n publicErrorMessage = error.stack ?? error.message;\n errorDetails = { stack: error.stack, name: error.name };\n } else {\n publicErrorMessage = String(error);\n }\n } else {\n if (process.env.NODE_ENV === 'production') {\n if (error instanceof Error) {\n publicErrorMessage = 'Something went wrong';\n } else if (typeof error === 'string') {\n publicErrorMessage = error;\n } else {\n publicErrorMessage = 'An unknown error occurred';\n }\n } else {\n if (error instanceof Error) {\n publicErrorMessage = error.stack ?? error.message;\n errorDetails = { stack: error.stack, name: error.name };\n } else {\n publicErrorMessage = String(error);\n }\n }\n }\n\n Logger.custom({ level: 'webServer', message: error });\n console.error(error);\n\n const apiError: ApiError = {\n message: publicErrorMessage,\n type: errorType ?? this.getErrorType(statusCode),\n timestamp: new Date().toISOString(),\n requestId: reply.request.id || 'unknown',\n ...(errorDetails && { details: errorDetails }),\n };\n\n const response: ApiResponse = { error: apiError };\n reply.status(statusCode).send(response);\n }\n\n private getErrorType(statusCode: StatusCodes): ApiError['type'] {\n switch (statusCode) {\n case StatusCodes.UNAUTHORIZED:\n return 'authentication';\n case StatusCodes.FORBIDDEN:\n return 'authorization';\n case StatusCodes.NOT_FOUND:\n return 'not_found';\n case StatusCodes.BAD_REQUEST:\n case StatusCodes.UNPROCESSABLE_ENTITY:\n return 'validation';\n case StatusCodes.INTERNAL_SERVER_ERROR:\n case StatusCodes.BAD_GATEWAY:\n case StatusCodes.SERVICE_UNAVAILABLE:\n return 'server_error';\n default:\n return 'client_error';\n }\n }\n\n protected async authenticateRequest(request: FastifyRequest, reply: FastifyReply): Promise<AuthenticatedUser | null> {\n // Get JWT secret key from application config\n const jwtSecretKey = this.applicationConfig.auth?.jwtSecretKey;\n\n if (!jwtSecretKey) {\n this.sendErrorResponse({\n reply,\n error: 'Authentication not configured.',\n statusCode: StatusCodes.INTERNAL_SERVER_ERROR,\n errorType: 'server_error',\n });\n return null;\n }\n\n const authHeader = request.headers.authorization;\n\n if (!authHeader) {\n this.sendErrorResponse({\n reply,\n error: 'No token provided.',\n statusCode: StatusCodes.UNAUTHORIZED,\n errorType: 'authentication',\n });\n return null;\n }\n\n if (!authHeader.startsWith('Bearer ')) {\n this.sendErrorResponse({\n reply,\n error: 'Invalid token.',\n statusCode: StatusCodes.UNAUTHORIZED,\n errorType: 'authentication',\n });\n return null;\n }\n\n try {\n const importedJwtSecretKey = await Jwt.importJwtSecretKey({\n jwtSecretKey,\n });\n\n // Remove \"Bearer \" from token\n const jwtAccessToken = authHeader.substring(7);\n\n const { payload } = await Jwt.jwtVerify(jwtAccessToken, importedJwtSecretKey);\n\n if (!payload.sub) {\n this.sendErrorResponse({\n reply,\n error: 'Invalid token payload.',\n statusCode: StatusCodes.UNAUTHORIZED,\n errorType: 'authentication',\n });\n return null;\n }\n\n const userId = parseInt(payload.sub);\n\n return {\n userId,\n payload,\n };\n } catch {\n this.sendErrorResponse({\n reply,\n error: 'Invalid or expired token.',\n statusCode: StatusCodes.UNAUTHORIZED,\n errorType: 'authentication',\n });\n return null;\n }\n }\n}\n"],
5
+ "mappings": ";;AAAA,SAAS,mBAAmB;AAM5B,SAAS,cAAc;AAGvB,OAAO,aAAa;AAEpB,OAAO,SAAS;AAQhB,MAAO,eAAsC;AAAA,EAnB7C,OAmB6C;AAAA;AAAA;AAAA,EACjC;AAAA,EAEA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEV,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAA6C;AAC3C,SAAK,WAAW,QAAQ,QAAQ;AAEhC,SAAK,oBAAoB;AACzB,SAAK,mBAAmB;AAExB,SAAK,gBAAgB;AACrB,SAAK,eAAe;AACpB,SAAK,eAAe;AACpB,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAEU,oBAA6B;AAAA,IACrC;AAAA,IACA;AAAA,IACA,aAAa,YAAY;AAAA,IACzB;AAAA,EACF,GAKG;AACD,UAAM,WAA2B;AAAA,MAC/B;AAAA,MACA,MAAM;AAAA,QACJ,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,QAClC,WAAW,MAAM,QAAQ,MAAM;AAAA,QAC/B,GAAG;AAAA,MACL;AAAA,IACF;AACA,UAAM,OAAO,UAAU,EAAE,KAAK,QAAQ;AAAA,EACxC;AAAA,EAEU,qBAAqB,OAAqB,UAAkB,sBAAsB;AAC1F,UAAM,QAAkB;AAAA,MACtB;AAAA,MACA,MAAM;AAAA,MACN,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,MAClC,WAAW,MAAM,QAAQ,MAAM;AAAA,IACjC;AACA,UAAM,WAAwB,EAAE,MAAM;AACtC,UAAM,OAAO,YAAY,SAAS,EAAE,KAAK,QAAQ;AAAA,EACnD;AAAA,EAEU,kBAAkB;A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F;AAAA,IACF,QAAQ;AACN,WAAK,kBAAkB;AAAA,QACrB;AAAA,QACA,OAAO;AAAA,QACP,YAAY,YAAY;AAAA,QACxB,WAAW;AAAA,MACb,CAAC;AACD,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,94 @@
1
+ import 'reflect-metadata';
2
+ import type { EntityManager } from '@mikro-orm/core';
3
+ import type { FastifyReply, FastifyRequest } from 'fastify';
4
+ import BaseController from './base.js';
5
+ import type { DynamicEntity } from '../../database/dynamic-entity.js';
6
+ import type { WebServerBaseControllerConstructorParams } from './base.interface.js';
7
+ export default abstract class EntityController extends BaseController {
8
+ protected abstract entityName: string;
9
+ protected entityManager: EntityManager;
10
+ private static entityCache;
11
+ constructor(props: WebServerBaseControllerConstructorParams);
12
+ protected getEntity: () => Promise<typeof DynamicEntity | undefined>;
13
+ private getEntityProperties;
14
+ options: (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
15
+ metadata: (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
16
+ protected preGetMany(_: {
17
+ entityManager: EntityManager;
18
+ request: FastifyRequest;
19
+ reply: FastifyReply;
20
+ }): Promise<void>;
21
+ protected postGetMany(_: {
22
+ entityManager: EntityManager;
23
+ request: FastifyRequest;
24
+ reply: FastifyReply;
25
+ data: {
26
+ items: any[];
27
+ total: number;
28
+ page: number;
29
+ totalPages: number;
30
+ limit: number;
31
+ };
32
+ }): Promise<void>;
33
+ getMany: (request: FastifyRequest<{
34
+ Querystring: {
35
+ page: string;
36
+ limit: string;
37
+ filters: string;
38
+ sort: string;
39
+ "sort-order": string;
40
+ search: string;
41
+ [key: string]: any;
42
+ };
43
+ }>, reply: FastifyReply) => Promise<void>;
44
+ protected preGetOne(_: {
45
+ entityManager: EntityManager;
46
+ request: FastifyRequest;
47
+ reply: FastifyReply;
48
+ }): Promise<void>;
49
+ protected postGetOne(_: {
50
+ entityManager: EntityManager;
51
+ request: FastifyRequest;
52
+ reply: FastifyReply;
53
+ item: any;
54
+ }): Promise<void>;
55
+ getOne: (request: FastifyRequest<{
56
+ Params: {
57
+ id: number;
58
+ };
59
+ Querystring: {
60
+ populate: string;
61
+ };
62
+ }>, reply: FastifyReply) => Promise<void>;
63
+ protected preCreateOne: ({ request, reply, }: {
64
+ request: FastifyRequest;
65
+ reply: FastifyReply;
66
+ }) => {
67
+ request: FastifyRequest;
68
+ reply: FastifyReply;
69
+ };
70
+ protected postCreateOne(_: {
71
+ entityManager: EntityManager;
72
+ request: FastifyRequest;
73
+ reply: FastifyReply;
74
+ item: any;
75
+ }): Promise<void>;
76
+ createOne: (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
77
+ protected postUpdateOne(_: {
78
+ entityManager: EntityManager;
79
+ request: FastifyRequest;
80
+ reply: FastifyReply;
81
+ item: any;
82
+ }): Promise<void>;
83
+ updateOne: (request: FastifyRequest<{
84
+ Params: {
85
+ id: number;
86
+ };
87
+ }>, reply: FastifyReply) => Promise<void>;
88
+ deleteOne: (request: FastifyRequest<{
89
+ Params: {
90
+ id: number;
91
+ };
92
+ }>, reply: FastifyReply) => Promise<void>;
93
+ }
94
+ //# sourceMappingURL=entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/webserver/controller/entity.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAyB,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE5D,OAAO,cAAc,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAGtE,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,qBAAqB,CAAC;AAEpF,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,gBAAiB,SAAQ,cAAc;IACnE,SAAS,CAAC,QAA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C,EAAE,OAAO,YAAY,mBAuChG;IAEK,SAAS,GAAU,SAAS,cAAc,CAAC;QAAE,MAAM,EAAE;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC,EAAE,OAAO,YAAY,mBAwBhG;CACH"}
@@ -0,0 +1,361 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import "reflect-metadata";
4
+ import path from "path";
5
+ import { StatusCodes } from "http-status-codes";
6
+ import BaseController from "./base.js";
7
+ import { generateFormFields } from "../../database/dynamic-entity-form-decorators.js";
8
+ import { Helper } from "../../util/index.js";
9
+ class EntityController extends BaseController {
10
+ static {
11
+ __name(this, "EntityController");
12
+ }
13
+ entityManager;
14
+ // Cache for entity modules to avoid repeated dynamic imports
15
+ static entityCache = /* @__PURE__ */ new Map();
16
+ constructor(props) {
17
+ super(props);
18
+ const { databaseInstance } = props;
19
+ this.entityManager = databaseInstance.getEntityManager();
20
+ }
21
+ getEntity = /* @__PURE__ */ __name(async () => {
22
+ if (!this.applicationConfig.database || this.applicationConfig.database.enabled !== true) {
23
+ throw new Error(`Database not enabled (Entity: ${this.entityName})`);
24
+ }
25
+ const cacheKey = `${this.applicationConfig.database.entitiesDirectory}:${this.entityName}`;
26
+ if (EntityController.entityCache.has(cacheKey)) {
27
+ return EntityController.entityCache.get(cacheKey);
28
+ }
29
+ const entityModulePath = path.join(
30
+ this.applicationConfig.database.entitiesDirectory,
31
+ `${this.entityName}.${Helper.getScriptFileExtension()}`
32
+ );
33
+ const entityModule = await import(entityModulePath);
34
+ if (!entityModule?.[this.entityName]) {
35
+ throw new Error(`Entity not found (Entity: ${this.entityName})`);
36
+ }
37
+ const EntityClass = entityModule[this.entityName];
38
+ EntityController.entityCache.set(cacheKey, EntityClass);
39
+ return EntityClass;
40
+ }, "getEntity");
41
+ getEntityProperties(entityClass) {
42
+ const properties = [];
43
+ const reservedPropertyKeys = ["constructor", "toJSON"];
44
+ for (const propertyKey of Object.getOwnPropertyNames(entityClass.prototype)) {
45
+ if (propertyKey.startsWith("__")) {
46
+ continue;
47
+ } else if (reservedPropertyKeys.includes(propertyKey)) {
48
+ continue;
49
+ }
50
+ properties.push(propertyKey);
51
+ }
52
+ return properties;
53
+ }
54
+ options = /* @__PURE__ */ __name(async (request, reply) => {
55
+ try {
56
+ const EntityClass = await this.getEntity();
57
+ if (!EntityClass) {
58
+ this.sendErrorResponse({ reply, error: "Entity not found" });
59
+ return;
60
+ }
61
+ const formFields = generateFormFields({ model: EntityClass });
62
+ this.sendSuccessResponse({
63
+ reply,
64
+ data: {
65
+ formFields
66
+ }
67
+ });
68
+ } catch (error) {
69
+ this.sendErrorResponse({ reply, error });
70
+ }
71
+ }, "options");
72
+ metadata = /* @__PURE__ */ __name(async (request, reply) => {
73
+ try {
74
+ const EntityClass = await this.getEntity();
75
+ if (!EntityClass) {
76
+ this.sendErrorResponse({ reply, error: "Entity not found" });
77
+ return;
78
+ }
79
+ const formFields = generateFormFields({ model: EntityClass });
80
+ this.sendSuccessResponse({
81
+ reply,
82
+ data: {
83
+ formFields
84
+ }
85
+ });
86
+ } catch (error) {
87
+ this.sendErrorResponse({ reply, error });
88
+ }
89
+ }, "metadata");
90
+ // Pre-getMany hook (can be overridden in the child controller)
91
+ async preGetMany(_) {
92
+ }
93
+ // Post-getMany hook (can be overridden in the child controller)
94
+ // await this.postGetMany({ entityManager: this.entityManager, request, reply, data });
95
+ async postGetMany(_) {
96
+ }
97
+ getMany = /* @__PURE__ */ __name(async (request, reply) => {
98
+ try {
99
+ await this.preGetMany({
100
+ entityManager: this.entityManager,
101
+ request,
102
+ reply
103
+ });
104
+ const EntityClass = await this.getEntity();
105
+ if (!EntityClass) {
106
+ this.sendErrorResponse({ reply, error: "Entity not found" });
107
+ return;
108
+ }
109
+ const page = parseInt(request.query.page) || 1;
110
+ const limit = parseInt(request.query.limit);
111
+ const offset = (page - 1) * (limit > 0 ? limit : 0);
112
+ const filters = request.query.filters ? JSON.parse(request.query.filters) : {};
113
+ const sortOrder = request.query["sort-order"] || "ASC";
114
+ const orderBy = request.query.sort ? { [request.query.sort]: sortOrder } : { id: sortOrder };
115
+ const normalizedQuery = {};
116
+ for (const key in request.query) {
117
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
118
+ continue;
119
+ }
120
+ if (!Object.prototype.hasOwnProperty.call(request.query, key)) {
121
+ continue;
122
+ }
123
+ if (key.endsWith("[]")) {
124
+ const normalizedKey = key.slice(0, -2);
125
+ if (normalizedKey !== "__proto__" && normalizedKey !== "constructor" && normalizedKey !== "prototype") {
126
+ Reflect.set(normalizedQuery, normalizedKey, Reflect.get(request.query, key));
127
+ }
128
+ } else {
129
+ Reflect.set(normalizedQuery, key, Reflect.get(request.query, key));
130
+ }
131
+ }
132
+ const options = {
133
+ filters,
134
+ offset,
135
+ orderBy
136
+ };
137
+ if (limit > 0) {
138
+ options.limit = limit;
139
+ }
140
+ const entityProperties = this.getEntityProperties(EntityClass);
141
+ const reservedQueryKeys = ["page", "limit", "filters", "sort", "populate", "search"];
142
+ const searchQuery = request.query.search || "";
143
+ for (const key in normalizedQuery) {
144
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
145
+ continue;
146
+ }
147
+ if (!Object.prototype.hasOwnProperty.call(normalizedQuery, key)) {
148
+ continue;
149
+ }
150
+ if (reservedQueryKeys.includes(key)) {
151
+ continue;
152
+ }
153
+ if (!entityProperties.includes(key)) {
154
+ const [relation, subProperty] = key.split(".");
155
+ if (relation && subProperty) {
156
+ if (relation === "__proto__" || relation === "constructor" || relation === "prototype" || subProperty === "__proto__" || subProperty === "constructor" || subProperty === "prototype") {
157
+ continue;
158
+ }
159
+ let queryValue2 = Reflect.get(normalizedQuery, key);
160
+ if (!queryValue2) continue;
161
+ if (typeof queryValue2 === "string" && queryValue2.includes(",")) {
162
+ queryValue2 = queryValue2.split(",");
163
+ }
164
+ if (Array.isArray(queryValue2)) {
165
+ Reflect.set(options.filters, relation, {
166
+ [subProperty]: { $in: queryValue2 }
167
+ });
168
+ } else {
169
+ Reflect.set(options.filters, relation, {
170
+ [subProperty]: queryValue2
171
+ });
172
+ }
173
+ }
174
+ continue;
175
+ }
176
+ let queryValue = Reflect.get(normalizedQuery, key);
177
+ if (!queryValue) {
178
+ continue;
179
+ }
180
+ if (typeof queryValue === "string" && queryValue.includes(",")) {
181
+ queryValue = queryValue.split(",");
182
+ }
183
+ if (Array.isArray(queryValue)) {
184
+ Reflect.set(options.filters, key, { $in: queryValue });
185
+ } else {
186
+ Reflect.set(options.filters, key, queryValue);
187
+ }
188
+ }
189
+ if (searchQuery) {
190
+ const searchFields = EntityClass.getSearchFields();
191
+ options.filters.$or = searchFields.filter((field) => {
192
+ const isIntegerField = ["id", "originId"].includes(field);
193
+ return !isIntegerField;
194
+ }).map((field) => {
195
+ return {
196
+ [field]: { $like: `%${searchQuery}%` }
197
+ };
198
+ });
199
+ }
200
+ const populate = request.query.populate ? request.query.populate.split(",") : [];
201
+ const [items, total] = await this.entityManager.findAndCount(this.entityName, options.filters, {
202
+ limit: options.limit,
203
+ offset: options.offset,
204
+ orderBy: options.orderBy,
205
+ populate
206
+ });
207
+ const totalPages = limit > 0 ? Math.ceil(total / limit) : 1;
208
+ const data = {
209
+ items,
210
+ total,
211
+ page,
212
+ totalPages,
213
+ limit: limit > 0 ? limit : total
214
+ };
215
+ await this.postGetMany({
216
+ entityManager: this.entityManager,
217
+ request,
218
+ reply,
219
+ data
220
+ });
221
+ reply.send({
222
+ data: data.items,
223
+ total_items: data.total,
224
+ page: data.page,
225
+ total_pages: data.totalPages,
226
+ limit: data.limit
227
+ });
228
+ } catch (error) {
229
+ this.sendErrorResponse({ reply, error });
230
+ }
231
+ }, "getMany");
232
+ async preGetOne(_) {
233
+ }
234
+ async postGetOne(_) {
235
+ }
236
+ getOne = /* @__PURE__ */ __name(async (request, reply) => {
237
+ try {
238
+ await this.preGetOne({
239
+ entityManager: this.entityManager,
240
+ request,
241
+ reply
242
+ });
243
+ const queryPopulate = request.query.populate || null;
244
+ const populateList = queryPopulate ? queryPopulate.split(",") : [];
245
+ const populate = populateList.map((field) => `${field}.*`);
246
+ const EntityClass = await this.getEntity();
247
+ if (!EntityClass) {
248
+ this.sendErrorResponse({ reply, error: "Entity not found" });
249
+ return;
250
+ }
251
+ const id = request.params.id;
252
+ const item = await this.entityManager.findOne(this.entityName, { id }, { populate });
253
+ if (!item) {
254
+ return this.sendNotFoundResponse(reply, `${EntityClass.singularNameCapitalized} not found`);
255
+ }
256
+ await this.postGetOne({
257
+ entityManager: this.entityManager,
258
+ request,
259
+ reply,
260
+ item
261
+ });
262
+ this.sendSuccessResponse({ reply, data: item });
263
+ } catch (error) {
264
+ this.sendErrorResponse({ reply, error });
265
+ }
266
+ }, "getOne");
267
+ preCreateOne = /* @__PURE__ */ __name(({
268
+ request,
269
+ reply
270
+ }) => {
271
+ return { request, reply };
272
+ }, "preCreateOne");
273
+ async postCreateOne(_) {
274
+ }
275
+ createOne = /* @__PURE__ */ __name(async (request, reply) => {
276
+ try {
277
+ const EntityClass = await this.getEntity();
278
+ if (!EntityClass) {
279
+ this.sendErrorResponse({ reply, error: "Entity not found" });
280
+ return;
281
+ }
282
+ if (this.preCreateOne) {
283
+ const { request: preCreateOneRequest } = await this.preCreateOne({
284
+ request,
285
+ reply
286
+ });
287
+ if (preCreateOneRequest) {
288
+ request = preCreateOneRequest;
289
+ }
290
+ }
291
+ const { error, value } = EntityClass.validate(request.body, true);
292
+ if (error) {
293
+ return this.sendErrorResponse({ reply, error: error.message });
294
+ }
295
+ const item = this.entityManager.create(this.entityName, value);
296
+ await this.entityManager.persistAndFlush(item);
297
+ await this.postCreateOne({
298
+ entityManager: this.entityManager,
299
+ request,
300
+ reply,
301
+ item
302
+ });
303
+ this.sendSuccessResponse({ reply, data: item, statusCode: StatusCodes.CREATED });
304
+ } catch (error) {
305
+ this.sendErrorResponse({ reply, error });
306
+ }
307
+ }, "createOne");
308
+ async postUpdateOne(_) {
309
+ }
310
+ updateOne = /* @__PURE__ */ __name(async (request, reply) => {
311
+ try {
312
+ const EntityClass = await this.getEntity();
313
+ if (!EntityClass) {
314
+ this.sendErrorResponse({ reply, error: "Entity not found" });
315
+ return;
316
+ }
317
+ const id = request.params.id;
318
+ const { error, value } = EntityClass.validate(request.body, false);
319
+ if (error) {
320
+ return this.sendErrorResponse({ reply, error: error.message });
321
+ }
322
+ const item = await this.entityManager.findOne(this.entityName, { id });
323
+ if (!item) {
324
+ return this.sendNotFoundResponse(reply, `${EntityClass.singularNameCapitalized} not found`);
325
+ }
326
+ this.entityManager.assign(item, value);
327
+ await this.entityManager.persistAndFlush(item);
328
+ await this.postUpdateOne({
329
+ entityManager: this.entityManager,
330
+ request,
331
+ reply,
332
+ item
333
+ });
334
+ this.sendSuccessResponse({ reply, data: item });
335
+ } catch (error) {
336
+ this.sendErrorResponse({ reply, error });
337
+ }
338
+ }, "updateOne");
339
+ deleteOne = /* @__PURE__ */ __name(async (request, reply) => {
340
+ try {
341
+ const EntityClass = await this.getEntity();
342
+ if (!EntityClass) {
343
+ this.sendErrorResponse({ reply, error: "Entity not found" });
344
+ return;
345
+ }
346
+ const id = request.params.id;
347
+ const item = await this.entityManager.findOne(this.entityName, { id });
348
+ if (!item) {
349
+ return this.sendNotFoundResponse(reply, `${EntityClass.singularNameCapitalized} not found`);
350
+ }
351
+ await this.entityManager.removeAndFlush(item);
352
+ reply.status(StatusCodes.NO_CONTENT).send();
353
+ } catch (error) {
354
+ this.sendErrorResponse({ reply, error });
355
+ }
356
+ }, "deleteOne");
357
+ }
358
+ export {
359
+ EntityController as default
360
+ };
361
+ //# sourceMappingURL=entity.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/webserver/controller/entity.ts"],
4
+ "sourcesContent": ["import 'reflect-metadata';\nimport path from 'path';\nimport type { EntityManager, FilterQuery, Populate } from '@mikro-orm/core';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\nimport { StatusCodes } from 'http-status-codes';\nimport BaseController from './base.js';\nimport type { DynamicEntity } from '../../database/dynamic-entity.js';\nimport { generateFormFields } from '../../database/dynamic-entity-form-decorators.js';\nimport { Helper } from '../../util/index.js';\nimport type { WebServerBaseControllerConstructorParams } from './base.interface.js';\n\nexport default abstract class EntityController extends BaseController {\n protected abstract entityName: string;\n\n protected entityManager: EntityManager;\n\n // Cache for entity modules to avoid repeated dynamic imports\n private static entityCache = new Map<string, typeof DynamicEntity>();\n\n constructor(props: WebServerBaseControllerConstructorParams) {\n super(props);\n\n const { databaseInstance } = props;\n\n this.entityManager = databaseInstance.getEntityManager();\n }\n\n protected getEntity = async (): Promise<typeof DynamicEntity | undefined> => {\n if (!this.applicationConfig.database || this.applicationConfig.database.enabled !== true) {\n throw new Error(`Database not enabled (Entity: ${this.entityName})`);\n }\n\n // Check cache first\n const cacheKey = `${this.applicationConfig.database.entitiesDirectory}:${this.entityName}`;\n if (EntityController.entityCache.has(cacheKey)) {\n return EntityController.entityCache.get(cacheKey);\n }\n\n // Define entity module path\n const entityModulePath = path.join(\n this.applicationConfig.database.entitiesDirectory,\n `${this.entityName}.${Helper.getScriptFileExtension()}`,\n );\n\n // Import entity module\n const entityModule = await import(entityModulePath);\n\n if (!entityModule?.[this.entityName]) {\n throw new Error(`Entity not found (Entity: ${this.entityName})`);\n }\n\n // Get entity class\n const EntityClass = entityModule[this.entityName];\n\n // Cache the entity for future use\n EntityController.entityCache.set(cacheKey, EntityClass);\n\n return EntityClass;\n };\n\n private getEntityProperties(entityClass: any): string[] {\n const properties: string[] = [];\n\n const reservedPropertyKeys = ['constructor', 'toJSON'];\n\n for (const propertyKey of Object.getOwnPropertyNames(entityClass.prototype)) {\n if (propertyKey.startsWith('__')) {\n continue;\n } else if (reservedPropertyKeys.includes(propertyKey)) {\n continue;\n }\n\n properties.push(propertyKey);\n }\n\n return properties;\n }\n\n public options = async (request: FastifyRequest, reply: FastifyReply) => {\n try {\n const EntityClass = await this.getEntity();\n\n if (!EntityClass) {\n this.sendErrorResponse({ reply, error: 'Entity not found' });\n\n return;\n }\n\n const formFields = generateFormFields({ model: EntityClass });\n\n this.sendSuccessResponse({\n reply,\n data: {\n formFields,\n },\n });\n } catch (error) {\n this.sendErrorResponse({ reply, error });\n }\n };\n\n public metadata = async (request: FastifyRequest, reply: FastifyReply) => {\n try {\n const EntityClass = await this.getEntity();\n\n if (!EntityClass) {\n this.sendErrorResponse({ reply, error: 'Entity not found' });\n\n return;\n }\n\n const formFields = generateFormFields({ model: EntityClass });\n\n this.sendSuccessResponse({\n reply,\n data: {\n formFields,\n },\n });\n } catch (error) {\n this.sendErrorResponse({ reply, error });\n }\n };\n\n // Pre-getMany hook (can be overridden in the child controller)\n protected async preGetMany(_: {\n entityManager: EntityManager;\n request: FastifyRequest;\n reply: FastifyReply;\n }): Promise<void> {\n // Default implementation: do nothing\n }\n\n // Post-getMany hook (can be overridden in the child controller)\n // await this.postGetMany({ entityManager: this.entityManager, request, reply, data });\n protected async postGetMany(_: {\n entityManager: EntityManager;\n request: FastifyRequest;\n reply: FastifyReply;\n data: {\n items: any[];\n total: number;\n page: number;\n totalPages: number;\n limit: number;\n };\n }): Promise<void> {\n // Default implementation: do nothing\n }\n\n public getMany = async (\n request: FastifyRequest<{\n Querystring: {\n page: string;\n limit: string;\n filters: string;\n sort: string;\n 'sort-order': string;\n search: string;\n [key: string]: any;\n };\n }>,\n reply: FastifyReply,\n ) => {\n try {\n // Call preGetMany hook\n await this.preGetMany({\n entityManager: this.entityManager,\n request,\n reply,\n });\n\n const EntityClass = await this.getEntity();\n\n if (!EntityClass) {\n this.sendErrorResponse({ reply, error: 'Entity not found' });\n\n return;\n }\n\n // Pagination parameters\n const page = parseInt(request.query.page) || 1;\n const limit = parseInt(request.query.limit);\n const offset = (page - 1) * (limit > 0 ? limit : 0);\n\n // Filtering and sorting\n const filters = request.query.filters ? JSON.parse(request.query.filters) : {};\n const sortOrder = request.query['sort-order'] || 'ASC';\n const orderBy = request.query.sort ? { [request.query.sort]: sortOrder } : { id: sortOrder };\n\n const normalizedQuery: { [key: string]: any } = {};\n\n for (const key in request.query) {\n // Skip prototype pollution attempts\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') {\n continue;\n }\n\n // Only process own properties\n if (!Object.prototype.hasOwnProperty.call(request.query, key)) {\n continue;\n }\n\n if (key.endsWith('[]')) {\n const normalizedKey = key.slice(0, -2);\n\n // Safe property assignment\n if (normalizedKey !== '__proto__' && normalizedKey !== 'constructor' && normalizedKey !== 'prototype') {\n Reflect.set(normalizedQuery, normalizedKey, Reflect.get(request.query, key));\n }\n } else {\n Reflect.set(normalizedQuery, key, Reflect.get(request.query, key));\n }\n }\n\n // Build query options\n const options: {\n limit?: number;\n offset?: number;\n filters: FilterQuery<any>;\n orderBy: { [key: string]: string };\n } = {\n filters,\n offset,\n orderBy,\n };\n\n if (limit > 0) {\n options.limit = limit;\n }\n\n const entityProperties = this.getEntityProperties(EntityClass);\n const reservedQueryKeys = ['page', 'limit', 'filters', 'sort', 'populate', 'search'];\n const searchQuery = request.query.search || '';\n\n for (const key in normalizedQuery) {\n // Skip prototype pollution attempts\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') {\n continue;\n }\n\n // Only process own properties\n if (!Object.prototype.hasOwnProperty.call(normalizedQuery, key)) {\n continue;\n }\n\n if (reservedQueryKeys.includes(key)) {\n continue;\n }\n\n if (!entityProperties.includes(key)) {\n const [relation, subProperty] = key.split('.');\n\n if (relation && subProperty) {\n // Validate relation and subProperty names\n if (\n relation === '__proto__' ||\n relation === 'constructor' ||\n relation === 'prototype' ||\n subProperty === '__proto__' ||\n subProperty === 'constructor' ||\n subProperty === 'prototype'\n ) {\n continue;\n }\n\n let queryValue = Reflect.get(normalizedQuery, key);\n\n if (!queryValue) continue;\n\n if (typeof queryValue === 'string' && queryValue.includes(',')) {\n queryValue = queryValue.split(',');\n }\n\n if (Array.isArray(queryValue)) {\n Reflect.set(options.filters, relation, {\n [subProperty]: { $in: queryValue },\n });\n } else {\n Reflect.set(options.filters, relation, {\n [subProperty]: queryValue,\n });\n }\n }\n\n continue;\n }\n\n let queryValue = Reflect.get(normalizedQuery, key);\n\n if (!queryValue) {\n continue;\n }\n\n if (typeof queryValue === 'string' && queryValue.includes(',')) {\n queryValue = queryValue.split(',');\n }\n\n if (Array.isArray(queryValue)) {\n Reflect.set(options.filters, key, { $in: queryValue });\n } else {\n Reflect.set(options.filters, key, queryValue);\n }\n }\n\n // Add search filter if a search query is provided\n if (searchQuery) {\n const searchFields = EntityClass.getSearchFields();\n\n options.filters.$or = searchFields\n .filter(field => {\n const isIntegerField = ['id', 'originId'].includes(field);\n\n return !isIntegerField;\n })\n .map(field => {\n return {\n [field]: { $like: `%${searchQuery}%` },\n };\n });\n }\n\n const populate = request.query.populate ? request.query.populate.split(',') : [];\n\n // Fetch items from the database\n const [items, total] = await this.entityManager.findAndCount(this.entityName, options.filters, {\n limit: options.limit,\n offset: options.offset,\n orderBy: options.orderBy,\n populate,\n });\n\n const totalPages = limit > 0 ? Math.ceil(total / limit) : 1;\n\n const data = {\n items,\n total,\n page,\n totalPages,\n limit: limit > 0 ? limit : total,\n };\n\n // Call postGetMany hook\n await this.postGetMany({\n entityManager: this.entityManager,\n request,\n reply,\n data,\n });\n\n reply.send({\n data: data.items,\n total_items: data.total,\n page: data.page,\n total_pages: data.totalPages,\n limit: data.limit,\n });\n } catch (error) {\n this.sendErrorResponse({ reply, error });\n }\n };\n\n protected async preGetOne(_: {\n entityManager: EntityManager;\n request: FastifyRequest;\n reply: FastifyReply;\n }): Promise<void> {\n // Default implementation: do nothing\n }\n\n protected async postGetOne(_: {\n entityManager: EntityManager;\n request: FastifyRequest;\n reply: FastifyReply;\n item: any;\n }): Promise<void> {\n // Default implementation: do nothing\n }\n\n public getOne = async (\n request: FastifyRequest<{\n Params: { id: number };\n Querystring: { populate: string };\n }>,\n reply: FastifyReply,\n ) => {\n try {\n await this.preGetOne({\n entityManager: this.entityManager,\n request,\n reply,\n });\n\n const queryPopulate = request.query.populate || null;\n const populateList: string[] = queryPopulate ? queryPopulate.split(',') : [];\n\n // Ensure populate is typed correctly for MikroORM\n const populate = populateList.map(field => `${field}.*`) as unknown as Populate<\n object,\n `${string}.*` | `${string}.$infer`\n >;\n\n const EntityClass = await this.getEntity();\n\n if (!EntityClass) {\n this.sendErrorResponse({ reply, error: 'Entity not found' });\n return;\n }\n\n const id = request.params.id;\n\n const item = await this.entityManager.findOne(this.entityName, { id }, { populate });\n\n if (!item) {\n return this.sendNotFoundResponse(reply, `${EntityClass.singularNameCapitalized} not found`);\n }\n\n await this.postGetOne({\n entityManager: this.entityManager,\n request,\n reply,\n item,\n });\n\n this.sendSuccessResponse({ reply, data: item });\n } catch (error) {\n this.sendErrorResponse({ reply, error });\n }\n };\n\n protected preCreateOne = ({\n request,\n reply,\n }: {\n request: FastifyRequest;\n reply: FastifyReply;\n }): { request: FastifyRequest; reply: FastifyReply } => {\n return { request, reply };\n };\n\n protected async postCreateOne(_: {\n entityManager: EntityManager;\n request: FastifyRequest;\n reply: FastifyReply;\n item: any;\n }): Promise<void> {}\n\n public createOne = async (request: FastifyRequest, reply: FastifyReply) => {\n try {\n const EntityClass = await this.getEntity();\n\n if (!EntityClass) {\n this.sendErrorResponse({ reply, error: 'Entity not found' });\n return;\n }\n\n // Listen for preCreateOne hook\n if (this.preCreateOne) {\n const { request: preCreateOneRequest } = await this.preCreateOne({\n request,\n reply,\n });\n if (preCreateOneRequest) {\n request = preCreateOneRequest;\n }\n }\n\n const { error, value } = EntityClass.validate(request.body, true);\n\n if (error) {\n return this.sendErrorResponse({ reply, error: error.message });\n }\n\n const item = this.entityManager.create(this.entityName, value);\n\n await this.entityManager.persistAndFlush(item);\n\n // Call postCreateOne hook\n await this.postCreateOne({\n entityManager: this.entityManager,\n request,\n reply,\n item,\n });\n\n this.sendSuccessResponse({ reply, data: item, statusCode: StatusCodes.CREATED });\n } catch (error) {\n this.sendErrorResponse({ reply, error });\n }\n };\n\n protected async postUpdateOne(_: {\n entityManager: EntityManager;\n request: FastifyRequest;\n reply: FastifyReply;\n item: any;\n }): Promise<void> {}\n\n public updateOne = async (request: FastifyRequest<{ Params: { id: number } }>, reply: FastifyReply) => {\n try {\n const EntityClass = await this.getEntity();\n\n if (!EntityClass) {\n this.sendErrorResponse({ reply, error: 'Entity not found' });\n return;\n }\n\n const id = request.params.id;\n\n const { error, value } = EntityClass.validate(request.body, false);\n\n if (error) {\n return this.sendErrorResponse({ reply, error: error.message });\n }\n\n const item = await this.entityManager.findOne(this.entityName, { id });\n\n if (!item) {\n return this.sendNotFoundResponse(reply, `${EntityClass.singularNameCapitalized} not found`);\n }\n\n this.entityManager.assign(item, value);\n\n await this.entityManager.persistAndFlush(item);\n\n // Call postUpdateOne hook\n await this.postUpdateOne({\n entityManager: this.entityManager,\n request,\n reply,\n item,\n });\n\n this.sendSuccessResponse({ reply, data: item });\n } catch (error) {\n this.sendErrorResponse({ reply, error });\n }\n };\n\n public deleteOne = async (request: FastifyRequest<{ Params: { id: number } }>, reply: FastifyReply) => {\n try {\n const EntityClass = await this.getEntity();\n\n if (!EntityClass) {\n this.sendErrorResponse({ reply, error: 'Entity not found' });\n\n return;\n }\n\n const id = request.params.id;\n\n const item = await this.entityManager.findOne(this.entityName, { id });\n\n if (!item) {\n return this.sendNotFoundResponse(reply, `${EntityClass.singularNameCapitalized} not found`);\n }\n\n await this.entityManager.removeAndFlush(item);\n\n reply.status(StatusCodes.NO_CONTENT).send();\n } catch (error) {\n this.sendErrorResponse({ reply, error });\n }\n };\n}\n"],
5
+ "mappings": ";;AAAA,OAAO;AACP,OAAO,UAAU;AAGjB,SAAS,mBAAmB;AAC5B,OAAO,oBAAoB;AAE3B,SAAS,0BAA0B;AACnC,SAAS,cAAc;AAGvB,MAAO,yBAAgD,eAAe;AAAA,EAXtE,OAWsE;AAAA;AAAA;AAAA,EAG1D;AAAA;AAAA,EAGV,OAAe,cAAc,oBAAI,IAAkC;AAAA,EAEnE,YAAY,OAAiD;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,KAAK,cAAc,gBAAgB,IAAI;AAG7C,YAAM,KAAK,cAAc;AAAA,QACvB,eAAe,KAAK;AAAA,QACpB;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAED,WAAK,oBAAoB,EAAE,OAAO,MAAM,KAAK,CAAC;AAAA,IAChD,SAAS,OAAO;AACd,WAAK,kBAAkB,EAAE,OAAO,MAAM,CAAC;AAAA,IACzC;AAAA,EACF,GAvCmB;AAAA,EAyCZ,YAAY,8BAAO,SAAqD,UAAwB;AACrG,QAAI;AACF,YAAM,cAAc,MAAM,KAAK,UAAU;AAEzC,UAAI,CAAC,aAAa;AAChB,aAAK,kBAAkB,EAAE,OAAO,OAAO,mBAAmB,CAAC;AAE3D;AAAA,MACF;AAEA,YAAM,KAAK,QAAQ,OAAO;AAE1B,YAAM,OAAO,MAAM,KAAK,cAAc,QAAQ,KAAK,YAAY,EAAE,GAAG,CAAC;AAErE,UAAI,CAAC,MAAM;AACT,eAAO,KAAK,qBAAqB,OAAO,GAAG,YAAY,uBAAuB,YAAY;AAAA,MAC5F;AAEA,YAAM,KAAK,cAAc,eAAe,IAAI;AAE5C,YAAM,OAAO,YAAY,UAAU,EAAE,KAAK;AAAA,IAC5C,SAAS,OAAO;AACd,WAAK,kBAAkB,EAAE,OAAO,MAAM,CAAC;AAAA,IACzC;AAAA,EACF,GAxBmB;AAyBrB;",
6
+ "names": ["queryValue"]
7
+ }
@@ -0,0 +1,12 @@
1
+ import type { FastifyReply, FastifyRequest } from 'fastify';
2
+ import WebServerBaseController from './base.js';
3
+ /**
4
+ * Example controller demonstrating simplified authentication
5
+ */
6
+ export default class ExampleAuthController extends WebServerBaseController {
7
+ getUserTickers: import("./auth-middleware.js").RouteHandler;
8
+ getUserOrders: (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
9
+ getUserProfile: (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
10
+ private withAuthentication;
11
+ }
12
+ //# sourceMappingURL=example-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example-auth.d.ts","sourceRoot":"","sources":["../../../src/webserver/controller/example-auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,uBAAmD,MAAM,WAAW,CAAC;AAG5E;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,uBAAuB;IAEjE,cAAc,8CAWmB;IAGjC,aAAa,GAAU,SAAS,cAAc,EAAE,OAAO,YAAY,KAAG,OAAO,CAAC,IAAI,CAAC,CAexF;IAGK,cAAc,GAAU,SAAS,cAAc,EAAE,OAAO,YAAY,KAAG,OAAO,CAAC,IAAI,CAAC,CAWzF;YAGY,kBAAkB;CAcjC"}
@@ -0,0 +1,53 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import WebServerBaseController from "./base.js";
4
+ import { withAuth } from "./auth-middleware.js";
5
+ class ExampleAuthController extends WebServerBaseController {
6
+ static {
7
+ __name(this, "ExampleAuthController");
8
+ }
9
+ // Method 1: Using wrapper function approach
10
+ getUserTickers = withAuth(async (request, reply) => {
11
+ const { userId } = request.user;
12
+ const tickers = [
13
+ { id: 1, symbol: "AAPL", userId },
14
+ { id: 2, symbol: "GOOGL", userId }
15
+ ];
16
+ return this.sendSuccessResponse({ reply, data: tickers });
17
+ }, this.authenticateRequest.bind(this));
18
+ // Method 2: Manual authentication (original approach, now simplified)
19
+ getUserOrders = /* @__PURE__ */ __name(async (request, reply) => {
20
+ const user = await this.authenticateRequest(request, reply);
21
+ if (!user) {
22
+ return;
23
+ }
24
+ const orders = [
25
+ { id: 1, userId: user.userId, symbol: "AAPL", quantity: 10 },
26
+ { id: 2, userId: user.userId, symbol: "GOOGL", quantity: 5 }
27
+ ];
28
+ return this.sendSuccessResponse({ reply, data: orders });
29
+ }, "getUserOrders");
30
+ // Method 3: Creating a simple authenticated wrapper method
31
+ getUserProfile = /* @__PURE__ */ __name(async (request, reply) => {
32
+ return this.withAuthentication(request, reply, async (user) => {
33
+ const userProfile = {
34
+ userId: user.userId,
35
+ username: user.payload.username ?? "N/A",
36
+ email: user.payload.email ?? "N/A"
37
+ };
38
+ return this.sendSuccessResponse({ reply, data: userProfile });
39
+ });
40
+ }, "getUserProfile");
41
+ // Helper method for inline authentication
42
+ async withAuthentication(request, reply, handler) {
43
+ const user = await this.authenticateRequest(request, reply);
44
+ if (!user) {
45
+ return;
46
+ }
47
+ return handler(user);
48
+ }
49
+ }
50
+ export {
51
+ ExampleAuthController as default
52
+ };
53
+ //# sourceMappingURL=example-auth.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/webserver/controller/example-auth.ts"],
4
+ "sourcesContent": ["import type { FastifyReply, FastifyRequest } from 'fastify';\nimport WebServerBaseController, { type AuthenticatedUser } from './base.js';\nimport { type AuthenticatedRequest, withAuth } from './auth-middleware.js';\n\n/**\n * Example controller demonstrating simplified authentication\n */\nexport default class ExampleAuthController extends WebServerBaseController {\n // Method 1: Using wrapper function approach\n public getUserTickers = withAuth(async (request: AuthenticatedRequest, reply: FastifyReply): Promise<void> => {\n // User is automatically authenticated and available on request.user\n const { userId } = request.user;\n\n // Your business logic here\n const tickers = [\n { id: 1, symbol: 'AAPL', userId },\n { id: 2, symbol: 'GOOGL', userId },\n ];\n\n return this.sendSuccessResponse({ reply, data: tickers });\n }, this.authenticateRequest.bind(this));\n\n // Method 2: Manual authentication (original approach, now simplified)\n public getUserOrders = async (request: FastifyRequest, reply: FastifyReply): Promise<void> => {\n const user = await this.authenticateRequest(request, reply);\n\n if (!user) {\n // Authentication failed, response already sent\n return;\n }\n\n // Your business logic here\n const orders = [\n { id: 1, userId: user.userId, symbol: 'AAPL', quantity: 10 },\n { id: 2, userId: user.userId, symbol: 'GOOGL', quantity: 5 },\n ];\n\n return this.sendSuccessResponse({ reply, data: orders });\n };\n\n // Method 3: Creating a simple authenticated wrapper method\n public getUserProfile = async (request: FastifyRequest, reply: FastifyReply): Promise<void> => {\n return this.withAuthentication(request, reply, async user => {\n // Your business logic here with authenticated user\n const userProfile = {\n userId: user.userId,\n username: user.payload.username ?? 'N/A',\n email: user.payload.email ?? 'N/A',\n };\n\n return this.sendSuccessResponse({ reply, data: userProfile });\n });\n };\n\n // Helper method for inline authentication\n private async withAuthentication(\n request: FastifyRequest,\n reply: FastifyReply,\n handler: (user: AuthenticatedUser) => Promise<void>,\n ): Promise<void> {\n const user = await this.authenticateRequest(request, reply);\n\n if (!user) {\n // Authentication failed, response already sent\n return;\n }\n\n return handler(user);\n }\n}\n"],
5
+ "mappings": ";;AACA,OAAO,6BAAyD;AAChE,SAAoC,gBAAgB;AAKpD,MAAO,8BAA4C,wBAAwB;AAAA,EAP3E,OAO2E;AAAA;AAAA;AAAA;AAAA,EAElE,iBAAiB,SAAS,OAAO,SAA+B,UAAuC;AAE5G,UAAM,EAAE,OAAO,IAAI,QAAQ;AAG3B,UAAM,UAAU;AAAA,MACd,EAAE,IAAI,GAAG,QAAQ,QAAQ,OAAO;AAAA,MAChC,EAAE,IAAI,GAAG,QAAQ,SAAS,OAAO;AAAA,IACnC;AAEA,WAAO,KAAK,oBAAoB,EAAE,OAAO,MAAM,QAAQ,CAAC;AAAA,EAC1D,GAAG,KAAK,oBAAoB,KAAK,IAAI,CAAC;AAAA;AAAA,EAG/B,gBAAgB,8BAAO,SAAyB,UAAuC;AAC5F,UAAM,OAAO,MAAM,KAAK,oBAAoB,SAAS,KAAK;AAE1D,QAAI,CAAC,MAAM;AAET;AAAA,IACF;AAGA,UAAM,SAAS;AAAA,MACb,EAAE,IAAI,GAAG,QAAQ,KAAK,QAAQ,QAAQ,QAAQ,UAAU,GAAG;AAAA,MAC3D,EAAE,IAAI,GAAG,QAAQ,KAAK,QAAQ,QAAQ,SAAS,UAAU,EAAE;AAAA,IAC7D;AAEA,WAAO,KAAK,oBAAoB,EAAE,OAAO,MAAM,OAAO,CAAC;AAAA,EACzD,GAfuB;AAAA;AAAA,EAkBhB,iBAAiB,8BAAO,SAAyB,UAAuC;AAC7F,WAAO,KAAK,mBAAmB,SAAS,OAAO,OAAM,SAAQ;AAE3D,YAAM,cAAc;AAAA,QAClB,QAAQ,KAAK;AAAA,QACb,UAAU,KAAK,QAAQ,YAAY;AAAA,QACnC,OAAO,KAAK,QAAQ,SAAS;AAAA,MAC/B;AAEA,aAAO,KAAK,oBAAoB,EAAE,OAAO,MAAM,YAAY,CAAC;AAAA,IAC9D,CAAC;AAAA,EACH,GAXwB;AAAA;AAAA,EAcxB,MAAc,mBACZ,SACA,OACA,SACe;AACf,UAAM,OAAO,MAAM,KAAK,oBAAoB,SAAS,KAAK;AAE1D,QAAI,CAAC,MAAM;AAET;AAAA,IACF;AAEA,WAAO,QAAQ,IAAI;AAAA,EACrB;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,8 @@
1
+ import type { FastifyReply, FastifyRequest } from 'fastify';
2
+ import BaseController from './base.js';
3
+ export default class HealthController extends BaseController {
4
+ health: (_: FastifyRequest, reply: FastifyReply) => Promise<void>;
5
+ private checkDatabaseConnection;
6
+ private checkRedisConnection;
7
+ }
8
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/webserver/controller/health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,cAAc,MAAM,WAAW,CAAC;AAEvC,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IACnD,MAAM,GAAU,GAAG,cAAc,EAAE,OAAO,YAAY,KAAG,OAAO,CAAC,IAAI,CAAC,CA4B3E;YAEY,uBAAuB;YAQvB,oBAAoB;CAOnC"}