@geekmidas/constructs 7.0.1 → 10.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (385) hide show
  1. package/README.md +71 -44
  2. package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts → AWSScheduledFunction-BvFvBsBN.d.cts} +10 -5
  3. package/dist/{AWSScheduledFunction-ysaCsdWx.d.mts.map → AWSScheduledFunction-BvFvBsBN.d.cts.map} +1 -1
  4. package/dist/{AWSScheduledFunction-CTIa90EH.d.cts → AWSScheduledFunction-CVccZO-L.d.mts} +10 -5
  5. package/dist/{AWSScheduledFunction-CTIa90EH.d.cts.map → AWSScheduledFunction-CVccZO-L.d.mts.map} +1 -1
  6. package/dist/{AWSScheduledFunction-CufMMhGB.mjs → AWSScheduledFunction-Db1lttJH.mjs} +3 -3
  7. package/dist/{AWSScheduledFunction-CufMMhGB.mjs.map → AWSScheduledFunction-Db1lttJH.mjs.map} +1 -1
  8. package/dist/{AWSScheduledFunction-DbkDr8CA.cjs → AWSScheduledFunction-qu4ieRZR.cjs} +9 -9
  9. package/dist/{AWSScheduledFunction-DbkDr8CA.cjs.map → AWSScheduledFunction-qu4ieRZR.cjs.map} +1 -1
  10. package/dist/{Construct-_1wX7p_Y.d.cts → Construct-B-xc0SE9.d.mts} +27 -5
  11. package/dist/Construct-B-xc0SE9.d.mts.map +1 -0
  12. package/dist/{Construct-r0U2zBwW.mjs → Construct-HmWM6YYu.mjs} +4 -3
  13. package/dist/Construct-HmWM6YYu.mjs.map +1 -0
  14. package/dist/{Construct-DCMuYOox.d.mts → Construct-WhCXIOPV.d.cts} +29 -7
  15. package/dist/Construct-WhCXIOPV.d.cts.map +1 -0
  16. package/dist/{Construct-vXMZJgRp.cjs → Construct-roId57cU.cjs} +7 -43
  17. package/dist/Construct-roId57cU.cjs.map +1 -0
  18. package/dist/{lazyAccessors-DmTG8sQH.cjs → Endpoint-BBkV6l0k.cjs} +869 -1079
  19. package/dist/Endpoint-BBkV6l0k.cjs.map +1 -0
  20. package/dist/{lazyAccessors-DfqZR6C4.mjs → Endpoint-BGwpNEX4.mjs} +840 -1003
  21. package/dist/Endpoint-BGwpNEX4.mjs.map +1 -0
  22. package/dist/{Endpoint-CAzNbDEt.d.cts → Endpoint-BnxZqIX-.d.cts} +53 -4
  23. package/dist/Endpoint-BnxZqIX-.d.cts.map +1 -0
  24. package/dist/{Endpoint-CLPSIl6S.d.mts → Endpoint-ROcXU-eH.d.mts} +55 -6
  25. package/dist/Endpoint-ROcXU-eH.d.mts.map +1 -0
  26. package/dist/EndpointFactory-DYoGLaIT.cjs +850 -0
  27. package/dist/EndpointFactory-DYoGLaIT.cjs.map +1 -0
  28. package/dist/EndpointFactory-Di0X9AWp.mjs +808 -0
  29. package/dist/EndpointFactory-Di0X9AWp.mjs.map +1 -0
  30. package/dist/{HonoEndpointAdaptor-DJDT3PMx.mjs → HonoEndpointAdaptor-DFKIIG2o.mjs} +5 -4
  31. package/dist/HonoEndpointAdaptor-DFKIIG2o.mjs.map +1 -0
  32. package/dist/{HonoEndpointAdaptor-CkJENANP.cjs → HonoEndpointAdaptor-wMsCyMgt.cjs} +24 -23
  33. package/dist/HonoEndpointAdaptor-wMsCyMgt.cjs.map +1 -0
  34. package/dist/{Queue-DaxjwmOQ.d.cts → Queue-D6WeziRD.d.cts} +43 -4
  35. package/dist/Queue-D6WeziRD.d.cts.map +1 -0
  36. package/dist/{Queue-HBDf0fqz.d.mts → Queue-DpUeqdC8.d.mts} +43 -4
  37. package/dist/Queue-DpUeqdC8.d.mts.map +1 -0
  38. package/dist/{Subscriber-B69ngPwl.d.cts → Subscriber-4rBJgDKI.d.mts} +9 -4
  39. package/dist/{Subscriber-B69ngPwl.d.cts.map → Subscriber-4rBJgDKI.d.mts.map} +1 -1
  40. package/dist/{Subscriber-D8Xm-86W.d.mts → Subscriber-DVQowdyj.d.cts} +11 -6
  41. package/dist/Subscriber-DVQowdyj.d.cts.map +1 -0
  42. package/dist/{Topic-C5ZMfveW.d.cts → Topic-Ohx9dvWr.d.cts} +33 -2
  43. package/dist/Topic-Ohx9dvWr.d.cts.map +1 -0
  44. package/dist/{Topic-DT10AqHk.d.mts → Topic-cmy2jOUy.d.mts} +33 -2
  45. package/dist/Topic-cmy2jOUy.d.mts.map +1 -0
  46. package/dist/adaptors/aws.cjs +39 -26
  47. package/dist/adaptors/aws.cjs.map +1 -1
  48. package/dist/adaptors/aws.d.cts +24 -16
  49. package/dist/adaptors/aws.d.cts.map +1 -1
  50. package/dist/adaptors/aws.d.mts +25 -17
  51. package/dist/adaptors/aws.d.mts.map +1 -1
  52. package/dist/adaptors/aws.mjs +26 -14
  53. package/dist/adaptors/aws.mjs.map +1 -1
  54. package/dist/adaptors/hono.cjs +9 -6
  55. package/dist/adaptors/hono.d.cts +7 -6
  56. package/dist/adaptors/hono.d.cts.map +1 -1
  57. package/dist/adaptors/hono.d.mts +8 -7
  58. package/dist/adaptors/hono.d.mts.map +1 -1
  59. package/dist/adaptors/hono.mjs +9 -6
  60. package/dist/adaptors/testing.cjs +18 -14
  61. package/dist/adaptors/testing.cjs.map +1 -1
  62. package/dist/adaptors/testing.d.cts +7 -6
  63. package/dist/adaptors/testing.d.cts.map +1 -1
  64. package/dist/adaptors/testing.d.mts +11 -10
  65. package/dist/adaptors/testing.d.mts.map +1 -1
  66. package/dist/adaptors/testing.mjs +10 -7
  67. package/dist/adaptors/testing.mjs.map +1 -1
  68. package/dist/auth.cjs +165 -0
  69. package/dist/auth.cjs.map +1 -0
  70. package/dist/auth.d.cts +108 -0
  71. package/dist/auth.d.cts.map +1 -0
  72. package/dist/auth.d.mts +108 -0
  73. package/dist/auth.d.mts.map +1 -0
  74. package/dist/auth.mjs +164 -0
  75. package/dist/auth.mjs.map +1 -0
  76. package/dist/cache-0ANvRQnD.mjs +51 -0
  77. package/dist/cache-0ANvRQnD.mjs.map +1 -0
  78. package/dist/cache-3WSvAulx.cjs +57 -0
  79. package/dist/cache-3WSvAulx.cjs.map +1 -0
  80. package/dist/cache-CdQ7OLpR.d.cts +47 -0
  81. package/dist/cache-CdQ7OLpR.d.cts.map +1 -0
  82. package/dist/cache-DYoJFcfd.d.mts +47 -0
  83. package/dist/cache-DYoJFcfd.d.mts.map +1 -0
  84. package/dist/cache.cjs +3 -0
  85. package/dist/cache.d.cts +3 -0
  86. package/dist/cache.d.mts +3 -0
  87. package/dist/cache.mjs +3 -0
  88. package/dist/chunk-DWy1uDak.cjs +39 -0
  89. package/dist/clone-DblgEZZa.mjs +39 -0
  90. package/dist/clone-DblgEZZa.mjs.map +1 -0
  91. package/dist/clone-Dy0cR2SZ.cjs +45 -0
  92. package/dist/clone-Dy0cR2SZ.cjs.map +1 -0
  93. package/dist/construct-interface-BfjcOD_E.cjs +117 -0
  94. package/dist/construct-interface-BfjcOD_E.cjs.map +1 -0
  95. package/dist/construct-interface-BqwRNYA2.d.mts +131 -0
  96. package/dist/construct-interface-BqwRNYA2.d.mts.map +1 -0
  97. package/dist/construct-interface-D2nNkHUN.d.cts +131 -0
  98. package/dist/construct-interface-D2nNkHUN.d.cts.map +1 -0
  99. package/dist/construct-interface-Z4CpS8tK.mjs +81 -0
  100. package/dist/construct-interface-Z4CpS8tK.mjs.map +1 -0
  101. package/dist/construct-interface.cjs +8 -0
  102. package/dist/construct-interface.d.cts +2 -0
  103. package/dist/construct-interface.d.mts +2 -0
  104. package/dist/construct-interface.mjs +3 -0
  105. package/dist/credential.cjs +96 -0
  106. package/dist/credential.cjs.map +1 -0
  107. package/dist/credential.d.cts +61 -0
  108. package/dist/credential.d.cts.map +1 -0
  109. package/dist/credential.d.mts +61 -0
  110. package/dist/credential.d.mts.map +1 -0
  111. package/dist/credential.mjs +94 -0
  112. package/dist/credential.mjs.map +1 -0
  113. package/dist/crons/index.cjs +39 -37
  114. package/dist/crons/index.cjs.map +1 -1
  115. package/dist/crons/index.d.cts +21 -8
  116. package/dist/crons/index.d.cts.map +1 -1
  117. package/dist/crons/index.d.mts +29 -13
  118. package/dist/crons/index.d.mts.map +1 -1
  119. package/dist/crons/index.mjs +37 -36
  120. package/dist/crons/index.mjs.map +1 -1
  121. package/dist/database/kysely.cjs +181 -0
  122. package/dist/database/kysely.cjs.map +1 -0
  123. package/dist/database/kysely.d.cts +152 -0
  124. package/dist/database/kysely.d.cts.map +1 -0
  125. package/dist/database/kysely.d.mts +152 -0
  126. package/dist/database/kysely.d.mts.map +1 -0
  127. package/dist/database/kysely.mjs +180 -0
  128. package/dist/database/kysely.mjs.map +1 -0
  129. package/dist/email.cjs +59 -0
  130. package/dist/email.cjs.map +1 -0
  131. package/dist/email.d.cts +50 -0
  132. package/dist/email.d.cts.map +1 -0
  133. package/dist/email.d.mts +50 -0
  134. package/dist/email.d.mts.map +1 -0
  135. package/dist/email.mjs +58 -0
  136. package/dist/email.mjs.map +1 -0
  137. package/dist/endpoints/index.cjs +21 -747
  138. package/dist/endpoints/index.d.cts +7 -343
  139. package/dist/endpoints/index.d.mts +7 -342
  140. package/dist/endpoints/index.mjs +11 -738
  141. package/dist/file-server.cjs +154 -0
  142. package/dist/file-server.cjs.map +1 -0
  143. package/dist/file-server.d.cts +156 -0
  144. package/dist/file-server.d.cts.map +1 -0
  145. package/dist/file-server.d.mts +156 -0
  146. package/dist/file-server.d.mts.map +1 -0
  147. package/dist/file-server.mjs +152 -0
  148. package/dist/file-server.mjs.map +1 -0
  149. package/dist/functions/index.cjs +4 -2
  150. package/dist/functions/index.d.cts +3 -2
  151. package/dist/functions/index.d.mts +3 -2
  152. package/dist/functions/index.mjs +4 -2
  153. package/dist/{functions-B-qt91O7.mjs → functions-CvT_q7Y4.mjs} +55 -51
  154. package/dist/functions-CvT_q7Y4.mjs.map +1 -0
  155. package/dist/{functions-C8i1kCMM.cjs → functions-DukjG8ov.cjs} +62 -57
  156. package/dist/functions-DukjG8ov.cjs.map +1 -0
  157. package/dist/index-7OcOWe75.d.cts +419 -0
  158. package/dist/index-7OcOWe75.d.cts.map +1 -0
  159. package/dist/index-Bt-F7u8L.d.mts +419 -0
  160. package/dist/index-Bt-F7u8L.d.mts.map +1 -0
  161. package/dist/{index-DP6fqv0I.d.mts → index-CPeqtKgq.d.mts} +48 -19
  162. package/dist/index-CPeqtKgq.d.mts.map +1 -0
  163. package/dist/{index-BGeTScmi.d.cts → index-Dadljnh_.d.cts} +36 -9
  164. package/dist/index-Dadljnh_.d.cts.map +1 -0
  165. package/dist/index.cjs +1 -1
  166. package/dist/index.d.cts +3 -3
  167. package/dist/index.d.mts +3 -3
  168. package/dist/index.mjs +1 -1
  169. package/dist/lazyAccessors-DM6HcXQk.mjs +175 -0
  170. package/dist/lazyAccessors-DM6HcXQk.mjs.map +1 -0
  171. package/dist/lazyAccessors-DrJj8NpA.cjs +223 -0
  172. package/dist/lazyAccessors-DrJj8NpA.cjs.map +1 -0
  173. package/dist/object-storage.cjs +48 -0
  174. package/dist/object-storage.cjs.map +1 -0
  175. package/dist/object-storage.d.cts +36 -0
  176. package/dist/object-storage.d.cts.map +1 -0
  177. package/dist/object-storage.d.mts +36 -0
  178. package/dist/object-storage.d.mts.map +1 -0
  179. package/dist/object-storage.mjs +47 -0
  180. package/dist/object-storage.mjs.map +1 -0
  181. package/dist/{processAudits-CKjjivyz.cjs → processAudits-Bc8rz6Ev.cjs} +3 -3
  182. package/dist/{processAudits-CKjjivyz.cjs.map → processAudits-Bc8rz6Ev.cjs.map} +1 -1
  183. package/dist/{processAudits-ySnizdMG.mjs → processAudits-D89tICM4.mjs} +1 -1
  184. package/dist/{processAudits-ySnizdMG.mjs.map → processAudits-D89tICM4.mjs.map} +1 -1
  185. package/dist/{publisher-BrFOF847.mjs → publisher-CGEo8UKD.mjs} +1 -1
  186. package/dist/{publisher-BrFOF847.mjs.map → publisher-CGEo8UKD.mjs.map} +1 -1
  187. package/dist/{publisher-lFQleddL.cjs → publisher-CqGsXB2X.cjs} +1 -1
  188. package/dist/{publisher-lFQleddL.cjs.map → publisher-CqGsXB2X.cjs.map} +1 -1
  189. package/dist/queue/index.cjs +92 -30
  190. package/dist/queue/index.cjs.map +1 -1
  191. package/dist/queue/index.d.cts +19 -4
  192. package/dist/queue/index.d.cts.map +1 -1
  193. package/dist/queue/index.d.mts +22 -6
  194. package/dist/queue/index.d.mts.map +1 -1
  195. package/dist/queue/index.mjs +90 -29
  196. package/dist/queue/index.mjs.map +1 -1
  197. package/dist/rest-api.cjs +187 -0
  198. package/dist/rest-api.cjs.map +1 -0
  199. package/dist/rest-api.d.cts +221 -0
  200. package/dist/rest-api.d.cts.map +1 -0
  201. package/dist/rest-api.d.mts +221 -0
  202. package/dist/rest-api.d.mts.map +1 -0
  203. package/dist/rest-api.mjs +186 -0
  204. package/dist/rest-api.mjs.map +1 -0
  205. package/dist/site.cjs +48 -0
  206. package/dist/site.cjs.map +1 -0
  207. package/dist/site.d.cts +101 -0
  208. package/dist/site.d.cts.map +1 -0
  209. package/dist/site.d.mts +101 -0
  210. package/dist/site.d.mts.map +1 -0
  211. package/dist/site.mjs +47 -0
  212. package/dist/site.mjs.map +1 -0
  213. package/dist/subscribers/index.cjs +35 -27
  214. package/dist/subscribers/index.cjs.map +1 -1
  215. package/dist/subscribers/index.d.cts +20 -5
  216. package/dist/subscribers/index.d.cts.map +1 -1
  217. package/dist/subscribers/index.d.mts +23 -7
  218. package/dist/subscribers/index.d.mts.map +1 -1
  219. package/dist/subscribers/index.mjs +34 -27
  220. package/dist/subscribers/index.mjs.map +1 -1
  221. package/dist/surfaceEnv-BFXEms2f.cjs +39 -0
  222. package/dist/surfaceEnv-BFXEms2f.cjs.map +1 -0
  223. package/dist/surfaceEnv-C3Ktahea.mjs +27 -0
  224. package/dist/surfaceEnv-C3Ktahea.mjs.map +1 -0
  225. package/dist/{telemetry-3vdxGn4q.d.mts → telemetry-C3L0iS28.d.cts} +2 -2
  226. package/dist/{telemetry-3vdxGn4q.d.mts.map → telemetry-C3L0iS28.d.cts.map} +1 -1
  227. package/dist/{telemetry-Dqx-D3F7.d.cts → telemetry-D7bVFLGi.d.mts} +2 -2
  228. package/dist/{telemetry-Dqx-D3F7.d.cts.map → telemetry-D7bVFLGi.d.mts.map} +1 -1
  229. package/dist/topic/index.cjs +56 -13
  230. package/dist/topic/index.cjs.map +1 -1
  231. package/dist/topic/index.d.cts +2 -2
  232. package/dist/topic/index.d.cts.map +1 -1
  233. package/dist/topic/index.d.mts +2 -2
  234. package/dist/topic/index.d.mts.map +1 -1
  235. package/dist/topic/index.mjs +54 -12
  236. package/dist/topic/index.mjs.map +1 -1
  237. package/dist/{types-BDNGr7pv.d.mts → types-BlAkSuGI.d.cts} +1 -1
  238. package/dist/{types-BDNGr7pv.d.mts.map → types-BlAkSuGI.d.cts.map} +1 -1
  239. package/dist/{types-BdAaYDvd.d.cts → types-aKksMEWL.d.mts} +1 -1
  240. package/dist/{types-BdAaYDvd.d.cts.map → types-aKksMEWL.d.mts.map} +1 -1
  241. package/dist/types.d.cts +1 -1
  242. package/dist/types.d.mts +1 -1
  243. package/package.json +155 -23
  244. package/CHANGELOG.md +0 -366
  245. package/dist/Construct-DCMuYOox.d.mts.map +0 -1
  246. package/dist/Construct-_1wX7p_Y.d.cts.map +0 -1
  247. package/dist/Construct-r0U2zBwW.mjs.map +0 -1
  248. package/dist/Construct-vXMZJgRp.cjs.map +0 -1
  249. package/dist/Endpoint-CAzNbDEt.d.cts.map +0 -1
  250. package/dist/Endpoint-CLPSIl6S.d.mts.map +0 -1
  251. package/dist/HonoEndpointAdaptor-CkJENANP.cjs.map +0 -1
  252. package/dist/HonoEndpointAdaptor-DJDT3PMx.mjs.map +0 -1
  253. package/dist/Queue-DaxjwmOQ.d.cts.map +0 -1
  254. package/dist/Queue-HBDf0fqz.d.mts.map +0 -1
  255. package/dist/Subscriber-D8Xm-86W.d.mts.map +0 -1
  256. package/dist/Topic-C5ZMfveW.d.cts.map +0 -1
  257. package/dist/Topic-DT10AqHk.d.mts.map +0 -1
  258. package/dist/endpoints/index.cjs.map +0 -1
  259. package/dist/endpoints/index.d.cts.map +0 -1
  260. package/dist/endpoints/index.d.mts.map +0 -1
  261. package/dist/endpoints/index.mjs.map +0 -1
  262. package/dist/functions-B-qt91O7.mjs.map +0 -1
  263. package/dist/functions-C8i1kCMM.cjs.map +0 -1
  264. package/dist/index-BGeTScmi.d.cts.map +0 -1
  265. package/dist/index-DP6fqv0I.d.mts.map +0 -1
  266. package/dist/lazyAccessors-DfqZR6C4.mjs.map +0 -1
  267. package/dist/lazyAccessors-DmTG8sQH.cjs.map +0 -1
  268. package/src/Construct.ts +0 -204
  269. package/src/__benchmarks__/build-time-optimization.bench.ts +0 -274
  270. package/src/__benchmarks__/endpoint.bench.ts +0 -494
  271. package/src/__benchmarks__/fixtures.ts +0 -241
  272. package/src/__benchmarks__/hono-adaptor.bench.ts +0 -533
  273. package/src/__benchmarks__/hono-server.bench.ts +0 -249
  274. package/src/__benchmarks__/response-builder.bench.ts +0 -428
  275. package/src/__benchmarks__/strategies/strategy-a-lazy-services.ts +0 -319
  276. package/src/__benchmarks__/strategies/strategy-c-middleware.ts +0 -530
  277. package/src/__benchmarks__/strategies/strategy-d-opt-in-events.ts +0 -567
  278. package/src/__tests__/Construct.environment.spec.ts +0 -704
  279. package/src/__tests__/publisher.setting.spec.ts +0 -508
  280. package/src/__tests__/publisher.spec.ts +0 -452
  281. package/src/adaptors/aws.ts +0 -6
  282. package/src/adaptors/hono.ts +0 -1
  283. package/src/adaptors/testing.ts +0 -11
  284. package/src/crons/AWSScheduledFunction.ts +0 -73
  285. package/src/crons/Cron.ts +0 -149
  286. package/src/crons/CronBuilder.ts +0 -271
  287. package/src/crons/__tests__/AWSScheduledFunction.spec.ts +0 -152
  288. package/src/crons/__tests__/Cron.spec.ts +0 -464
  289. package/src/crons/__tests__/CronBuilder.state-isolation.spec.ts +0 -227
  290. package/src/crons/index.ts +0 -12
  291. package/src/endpoints/AmazonApiGatewayEndpointAdaptor.ts +0 -677
  292. package/src/endpoints/AmazonApiGatewayV1EndpointAdaptor.ts +0 -105
  293. package/src/endpoints/AmazonApiGatewayV2EndpointAdaptor.ts +0 -97
  294. package/src/endpoints/Authorizer.ts +0 -152
  295. package/src/endpoints/Endpoint.ts +0 -1287
  296. package/src/endpoints/EndpointBuilder.ts +0 -758
  297. package/src/endpoints/EndpointFactory.ts +0 -1148
  298. package/src/endpoints/HonoEndpointAdaptor.ts +0 -677
  299. package/src/endpoints/MswEndpointAdaptor.ts +0 -226
  300. package/src/endpoints/TestEndpointAdaptor.ts +0 -422
  301. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.audits.spec.ts +0 -499
  302. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.events.spec.ts +0 -560
  303. package/src/endpoints/__tests__/AmazonApiGatewayV1EndpointAdaptor.spec.ts +0 -1304
  304. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.audits.spec.ts +0 -626
  305. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.events.spec.ts +0 -732
  306. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.factory-publisher.spec.ts +0 -296
  307. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.kysely-audit.integration.spec.ts +0 -951
  308. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.responseType.spec.ts +0 -111
  309. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.rls.spec.ts +0 -307
  310. package/src/endpoints/__tests__/AmazonApiGatewayV2EndpointAdaptor.spec.ts +0 -629
  311. package/src/endpoints/__tests__/Authorizer.spec.ts +0 -286
  312. package/src/endpoints/__tests__/Endpoint.cookies.spec.ts +0 -207
  313. package/src/endpoints/__tests__/Endpoint.headers.spec.ts +0 -187
  314. package/src/endpoints/__tests__/Endpoint.manifest.spec.ts +0 -175
  315. package/src/endpoints/__tests__/Endpoint.spec.ts +0 -857
  316. package/src/endpoints/__tests__/EndpointBuilder.audit.spec.ts +0 -448
  317. package/src/endpoints/__tests__/EndpointBuilder.responseType.spec.ts +0 -47
  318. package/src/endpoints/__tests__/EndpointBuilder.spec.ts +0 -523
  319. package/src/endpoints/__tests__/EndpointFactory.authorizers.spec.ts +0 -492
  320. package/src/endpoints/__tests__/EndpointFactory.database-auditor.spec.ts +0 -509
  321. package/src/endpoints/__tests__/EndpointFactory.reference-audit.spec.ts +0 -190
  322. package/src/endpoints/__tests__/EndpointFactory.spec.ts +0 -479
  323. package/src/endpoints/__tests__/EndpointFactory.state-isolation.spec.ts +0 -155
  324. package/src/endpoints/__tests__/HonoEndpointAdaptor.audit-transactions.spec.ts +0 -703
  325. package/src/endpoints/__tests__/HonoEndpointAdaptor.audits.spec.ts +0 -632
  326. package/src/endpoints/__tests__/HonoEndpointAdaptor.events.spec.ts +0 -577
  327. package/src/endpoints/__tests__/HonoEndpointAdaptor.kysely-audit.integration.spec.ts +0 -1067
  328. package/src/endpoints/__tests__/HonoEndpointAdaptor.openapi.spec.ts +0 -317
  329. package/src/endpoints/__tests__/HonoEndpointAdaptor.pgboss-publisher.spec.ts +0 -289
  330. package/src/endpoints/__tests__/HonoEndpointAdaptor.responseType.spec.ts +0 -128
  331. package/src/endpoints/__tests__/HonoEndpointAdaptor.spec.ts +0 -1207
  332. package/src/endpoints/__tests__/MswEndpointAdaptor.spec.ts +0 -211
  333. package/src/endpoints/__tests__/ResponseBuilder.spec.ts +0 -235
  334. package/src/endpoints/__tests__/TestEndpointAdaptor.audits.spec.ts +0 -602
  335. package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +0 -1044
  336. package/src/endpoints/__tests__/__snapshots__/HonoEndpointAdaptor.spec.ts.snap +0 -54
  337. package/src/endpoints/__tests__/endpoint-types.test.ts +0 -88
  338. package/src/endpoints/__tests__/helpers.spec.ts +0 -37
  339. package/src/endpoints/__tests__/lazyAccessors.spec.ts +0 -330
  340. package/src/endpoints/__tests__/processAudits.spec.ts +0 -631
  341. package/src/endpoints/audit.ts +0 -87
  342. package/src/endpoints/helpers.ts +0 -98
  343. package/src/endpoints/index.ts +0 -42
  344. package/src/endpoints/lazyAccessors.ts +0 -241
  345. package/src/endpoints/parseHonoQuery.ts +0 -16
  346. package/src/endpoints/parseQueryParams.ts +0 -32
  347. package/src/endpoints/processAudits.ts +0 -371
  348. package/src/endpoints/rls.ts +0 -67
  349. package/src/functions/AWSLambdaFunction.ts +0 -348
  350. package/src/functions/BaseFunctionBuilder.ts +0 -201
  351. package/src/functions/Function.ts +0 -238
  352. package/src/functions/FunctionBuilder.ts +0 -391
  353. package/src/functions/FunctionExecutionWrapper.ts +0 -216
  354. package/src/functions/TestFunctionAdaptor.ts +0 -217
  355. package/src/functions/__tests__/AWSLambdaFunctionAdaptor.spec.ts +0 -513
  356. package/src/functions/__tests__/Function.audits.spec.ts +0 -393
  357. package/src/functions/__tests__/Function.spec.ts +0 -477
  358. package/src/functions/__tests__/FunctionBuilder.state-isolation.spec.ts +0 -207
  359. package/src/functions/__tests__/TestFunctionAdaptor.spec.ts +0 -480
  360. package/src/functions/index.ts +0 -12
  361. package/src/index.ts +0 -23
  362. package/src/publisher.ts +0 -93
  363. package/src/queue/AWSLambdaQueueAdaptor.ts +0 -162
  364. package/src/queue/Queue.ts +0 -128
  365. package/src/queue/QueueBuilder.ts +0 -115
  366. package/src/queue/TestQueueAdaptor.ts +0 -63
  367. package/src/queue/__tests__/QueueBuilder.spec.ts +0 -137
  368. package/src/queue/index.ts +0 -12
  369. package/src/subscribers/AWSLambdaSubscriberAdaptor.ts +0 -342
  370. package/src/subscribers/Subscriber.ts +0 -117
  371. package/src/subscribers/SubscriberBuilder.ts +0 -186
  372. package/src/subscribers/TestSubscriberAdaptor.ts +0 -133
  373. package/src/subscribers/__tests__/AWSLambdaSubscriberAdaptor.spec.ts +0 -1018
  374. package/src/subscribers/__tests__/Subscriber.spec.ts +0 -430
  375. package/src/subscribers/__tests__/TestSubscriberAdaptor.spec.ts +0 -652
  376. package/src/subscribers/index.ts +0 -6
  377. package/src/telemetry.ts +0 -103
  378. package/src/topic/Topic.ts +0 -103
  379. package/src/topic/TopicBuilder.ts +0 -51
  380. package/src/topic/__tests__/TopicBuilder.spec.ts +0 -82
  381. package/src/topic/index.ts +0 -11
  382. package/src/types.ts +0 -13
  383. package/test.ts +0 -91
  384. package/tsconfig.json +0 -9
  385. package/tsdown.config.ts +0 -34
@@ -1,677 +0,0 @@
1
- import type { AuditableAction, AuditStorage } from '@geekmidas/audit';
2
- import { withRlsContext } from '@geekmidas/db/rls';
3
- import type { EnvironmentParser } from '@geekmidas/envkit';
4
- import { wrapError } from '@geekmidas/errors';
5
- import type { EventPublisher } from '@geekmidas/events';
6
- import type { Logger } from '@geekmidas/logger';
7
- import { checkRateLimit, getRateLimitHeaders } from '@geekmidas/rate-limit';
8
- import {
9
- runWithRequestContext,
10
- type Service,
11
- ServiceDiscovery,
12
- type ServiceRecord,
13
- } from '@geekmidas/services';
14
- import type { StandardSchemaV1 } from '@standard-schema/spec';
15
- import { type Context, Hono } from 'hono';
16
- import { setCookie } from 'hono/cookie';
17
- import { logger as honoLogger } from 'hono/logger';
18
- import { timing } from 'hono/timing';
19
- import type { ContentfulStatusCode } from 'hono/utils/http-status';
20
- import { validator } from 'hono/validator';
21
- import { publishConstructEvents } from '../publisher';
22
- import type { HttpMethod, LowerHttpMethod } from '../types';
23
- import type { MappedAudit } from './audit';
24
- import {
25
- Endpoint,
26
- type EndpointContext,
27
- type EndpointSchemas,
28
- ResponseBuilder,
29
- } from './Endpoint';
30
- import { getEndpointsFromRoutes } from './helpers';
31
- import { createHonoCookies, createHonoHeaders } from './lazyAccessors';
32
- import { parseHonoQuery } from './parseHonoQuery';
33
- import {
34
- createAuditContext,
35
- executeWithAuditTransaction,
36
- } from './processAudits';
37
-
38
- export interface HonoEndpointOptions {
39
- /**
40
- * Path where OpenAPI documentation will be served.
41
- * Set to false to disable docs route.
42
- * @default '/docs'
43
- */
44
- docsPath?: string | false;
45
- /**
46
- * OpenAPI schema options
47
- */
48
- openApiOptions?: {
49
- title?: string;
50
- version?: string;
51
- description?: string;
52
- };
53
- }
54
-
55
- /**
56
- * Feature flags for an endpoint, analyzed once at route registration time.
57
- * This avoids per-request feature detection overhead.
58
- */
59
- interface EndpointFeatures {
60
- hasServices: boolean;
61
- hasDatabase: boolean;
62
- hasBodyValidation: boolean;
63
- hasQueryValidation: boolean;
64
- hasParamValidation: boolean;
65
- hasAudits: boolean;
66
- hasEvents: boolean;
67
- hasRateLimit: boolean;
68
- hasRls: boolean;
69
- }
70
-
71
- /**
72
- * Case-insensitive check for a `content-type` header in a metadata headers map.
73
- */
74
- function hasContentTypeHeader(headers: Record<string, string>): boolean {
75
- for (const key of Object.keys(headers)) {
76
- if (key.toLowerCase() === 'content-type') return true;
77
- }
78
- return false;
79
- }
80
-
81
- /**
82
- * Analyze endpoint features at registration time (not per-request)
83
- */
84
- function analyzeEndpointFeatures(
85
- endpoint: Endpoint<
86
- any,
87
- any,
88
- any,
89
- any,
90
- any,
91
- any,
92
- any,
93
- any,
94
- any,
95
- any,
96
- any,
97
- any,
98
- any,
99
- any
100
- >,
101
- ): EndpointFeatures {
102
- return {
103
- hasServices: endpoint.services.length > 0,
104
- hasDatabase: !!endpoint.databaseService,
105
- hasBodyValidation: !!endpoint.input?.body,
106
- hasQueryValidation: !!endpoint.input?.query,
107
- hasParamValidation: !!endpoint.input?.params,
108
- // Audit context needed if declarative audits OR auditor storage service configured (for manual audits)
109
- hasAudits:
110
- (endpoint.audits?.length ?? 0) > 0 || !!endpoint.auditorStorageService,
111
- hasEvents: (endpoint.events?.length ?? 0) > 0,
112
- hasRateLimit: !!endpoint.rateLimit,
113
- hasRls: !!endpoint.rlsConfig && !endpoint.rlsBypass,
114
- };
115
- }
116
-
117
- export class HonoEndpoint<
118
- TRoute extends string,
119
- TMethod extends HttpMethod,
120
- TInput extends EndpointSchemas = {},
121
- TOutSchema extends StandardSchemaV1 | undefined = undefined,
122
- TServices extends Service[] = [],
123
- TLogger extends Logger = Logger,
124
- TSession = unknown,
125
- TEventPublisher extends EventPublisher<any> | undefined = undefined,
126
- TEventPublisherServiceName extends string = string,
127
- TAuditStorage extends AuditStorage | undefined = undefined,
128
- TAuditStorageServiceName extends string = string,
129
- TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
130
- string,
131
- unknown
132
- >,
133
- TDatabase = undefined,
134
- TDatabaseServiceName extends string = string,
135
- > {
136
- constructor(
137
- private readonly endpoint: Endpoint<
138
- TRoute,
139
- TMethod,
140
- TInput,
141
- TOutSchema,
142
- TServices,
143
- TLogger,
144
- TSession,
145
- TEventPublisher,
146
- TEventPublisherServiceName,
147
- TAuditStorage,
148
- TAuditStorageServiceName,
149
- TAuditAction,
150
- TDatabase,
151
- TDatabaseServiceName
152
- >,
153
- ) {}
154
-
155
- static isDev = process.env.NODE_ENV === 'development';
156
-
157
- static async validate<T extends StandardSchemaV1>(
158
- c: Context<any, string, {}>,
159
- data: unknown,
160
- schema?: T,
161
- ) {
162
- if (!schema) {
163
- return undefined;
164
- }
165
-
166
- const parsed = await Endpoint.validate(schema, data);
167
-
168
- if (parsed.issues) {
169
- return c.json(parsed.issues, 422);
170
- }
171
-
172
- return parsed.value;
173
- }
174
- addRoute(
175
- serviceDiscovery: ServiceDiscovery<ServiceRecord<TServices>>,
176
- app: Hono,
177
- ): void {
178
- HonoEndpoint.addRoute(this.endpoint, serviceDiscovery, app);
179
- }
180
-
181
- /**
182
- * @deprecated Global event middleware is no longer used.
183
- * Events are now published per-route only for endpoints that have events configured.
184
- * This method is kept for backward compatibility but does nothing.
185
- */
186
- static applyEventMiddleware(
187
- _app: Hono,
188
- _serviceDiscovery: ServiceDiscovery<any>,
189
- ) {
190
- // No-op: Event publishing is now handled per-route in addRoute
191
- // This avoids running middleware on every request including 404s
192
- }
193
-
194
- static async fromRoutes<TLogger extends Logger, TServices extends Service[]>(
195
- routes: string[],
196
- envParser: EnvironmentParser<{}>,
197
- app = new Hono(),
198
- _logger: TLogger,
199
- cwd = process.cwd(),
200
- options?: HonoEndpointOptions,
201
- ): Promise<Hono> {
202
- const endpoints = await getEndpointsFromRoutes<TServices>(routes, cwd);
203
- const serviceDiscovery =
204
- ServiceDiscovery.getInstance<ServiceRecord<TServices>>(envParser);
205
-
206
- HonoEndpoint.addRoutes(endpoints, serviceDiscovery, app, options);
207
-
208
- return app;
209
- }
210
-
211
- static addRoutes<
212
- TServices extends Service[] = [],
213
- TLogger extends Logger = Logger,
214
- >(
215
- endpoints: Endpoint<string, HttpMethod, any, any, TServices, TLogger>[],
216
- serviceDiscovery: ServiceDiscovery<ServiceRecord<TServices>>,
217
- app: Hono,
218
- options?: HonoEndpointOptions,
219
- ): void {
220
- // Add timing middleware (always enabled)
221
- app.use('*', timing());
222
-
223
- // Add logger middleware in development mode
224
-
225
- if (HonoEndpoint.isDev) {
226
- app.use('*', honoLogger());
227
- }
228
-
229
- // Add docs route if not disabled
230
- const docsPath =
231
- options?.docsPath !== false ? options?.docsPath || '/docs' : null;
232
- if (docsPath) {
233
- HonoEndpoint.addDocsRoute(
234
- endpoints,
235
- app,
236
- docsPath,
237
- options?.openApiOptions,
238
- );
239
- }
240
-
241
- // Sort endpoints to ensure static routes come before dynamic ones
242
- const sortedEndpoints = endpoints.sort((a, b) => {
243
- const aSegments = a.route.split('/');
244
- const bSegments = b.route.split('/');
245
-
246
- // Compare each segment
247
- for (let i = 0; i < Math.max(aSegments.length, bSegments.length); i++) {
248
- const aSegment = aSegments[i] || '';
249
- const bSegment = bSegments[i] || '';
250
-
251
- // If one is dynamic and the other is not, static comes first
252
- const aIsDynamic = aSegment.startsWith(':');
253
- const bIsDynamic = bSegment.startsWith(':');
254
-
255
- if (!aIsDynamic && bIsDynamic) return -1;
256
- if (aIsDynamic && !bIsDynamic) return 1;
257
-
258
- // If both are the same type, compare alphabetically
259
- if (aSegment !== bSegment) {
260
- return aSegment.localeCompare(bSegment);
261
- }
262
- }
263
-
264
- return 0;
265
- });
266
-
267
- // Note: Global event middleware removed for performance
268
- // Events are now published per-route only for endpoints with events configured
269
- for (const endpoint of sortedEndpoints) {
270
- HonoEndpoint.addRoute(endpoint, serviceDiscovery, app);
271
- }
272
- }
273
-
274
- static addRoute<
275
- TRoute extends string,
276
- TMethod extends HttpMethod,
277
- TInput extends EndpointSchemas = {},
278
- TOutSchema extends StandardSchemaV1 | undefined = undefined,
279
- TServices extends Service[] = [],
280
- TLogger extends Logger = Logger,
281
- TSession = unknown,
282
- TEventPublisher extends EventPublisher<any> | undefined = undefined,
283
- TEventPublisherServiceName extends string = string,
284
- TAuditStorage extends AuditStorage | undefined = undefined,
285
- TAuditStorageServiceName extends string = string,
286
- TAuditAction extends AuditableAction<string, unknown> = AuditableAction<
287
- string,
288
- unknown
289
- >,
290
- TDatabase = undefined,
291
- TDatabaseServiceName extends string = string,
292
- >(
293
- endpoint: Endpoint<
294
- TRoute,
295
- TMethod,
296
- TInput,
297
- TOutSchema,
298
- TServices,
299
- TLogger,
300
- TSession,
301
- TEventPublisher,
302
- TEventPublisherServiceName,
303
- TAuditStorage,
304
- TAuditStorageServiceName,
305
- TAuditAction,
306
- TDatabase,
307
- TDatabaseServiceName
308
- >,
309
- serviceDiscovery: ServiceDiscovery<ServiceRecord<TServices>>,
310
- app: Hono,
311
- ): void {
312
- const { route } = endpoint;
313
- const method = endpoint.method.toLowerCase() as LowerHttpMethod<TMethod>;
314
-
315
- // Analyze endpoint features once at registration time (not per-request)
316
- const features = analyzeEndpointFeatures(endpoint);
317
-
318
- // Build validators array - only add validators for schemas that exist
319
- const validators: any[] = [];
320
-
321
- if (features.hasBodyValidation) {
322
- validators.push(
323
- validator('json', (value, c) =>
324
- HonoEndpoint.validate(c, value, endpoint.input?.body),
325
- ),
326
- );
327
- }
328
-
329
- if (features.hasQueryValidation) {
330
- validators.push(
331
- validator('query', (_, c) => {
332
- const parsedQuery = parseHonoQuery(c);
333
- return HonoEndpoint.validate(c, parsedQuery, endpoint.input?.query);
334
- }),
335
- );
336
- }
337
-
338
- if (features.hasParamValidation) {
339
- validators.push(
340
- validator('param', (params, c) =>
341
- HonoEndpoint.validate(c, params, endpoint.input?.params),
342
- ),
343
- );
344
- }
345
-
346
- // Main handler
347
- const handler = async (c: Context) => {
348
- // Request context setup
349
- const startTime = Date.now();
350
- const requestId = c.req.header('X-Request-ID') ?? crypto.randomUUID();
351
-
352
- const logger = endpoint.logger.child({
353
- requestId,
354
- endpoint: endpoint.fullPath,
355
- route: endpoint.route,
356
- host: c.req.header('host'),
357
- method: endpoint.method,
358
- path: c.req.path,
359
- }) as TLogger;
360
-
361
- // Set response header
362
- c.header('X-Request-ID', requestId);
363
-
364
- // Wrap entire handler in request context for services to access
365
- return runWithRequestContext(
366
- { logger, requestId, startTime },
367
- async () => {
368
- try {
369
- // Lazy accessors - no upfront parsing, use native Hono methods
370
- const header = createHonoHeaders(c);
371
- const cookie = createHonoCookies(c);
372
-
373
- // Only register services if endpoint has any
374
- const services = features.hasServices
375
- ? await serviceDiscovery.register(endpoint.services)
376
- : ({} as ServiceRecord<TServices>);
377
-
378
- // Resolve database service only if configured
379
- const rawDb = features.hasDatabase
380
- ? await serviceDiscovery
381
- .register([endpoint.databaseService!])
382
- .then(
383
- (s) =>
384
- s[
385
- endpoint.databaseService?.serviceName as keyof typeof s
386
- ],
387
- )
388
- : undefined;
389
-
390
- // Extract session (defaults to empty object)
391
- const session = await endpoint.getSession({
392
- services,
393
- logger,
394
- header,
395
- cookie,
396
- ...(rawDb !== undefined && { db: rawDb }),
397
- } as any);
398
-
399
- // Check authorization (defaults to true)
400
- const isAuthorized = await endpoint.authorize({
401
- header,
402
- cookie,
403
- services,
404
- logger,
405
- session,
406
- ...(rawDb !== undefined && { db: rawDb }),
407
- body: features.hasBodyValidation
408
- ? (c.req.valid as any)('json')
409
- : undefined,
410
- query: features.hasQueryValidation
411
- ? (c.req.valid as any)('query')
412
- : undefined,
413
- params: features.hasParamValidation
414
- ? (c.req.valid as any)('param')
415
- : undefined,
416
- } as any);
417
-
418
- if (!isAuthorized) {
419
- logger.warn('Forbidden access attempt');
420
- return c.json({ error: 'Forbidden' }, 403);
421
- }
422
-
423
- // Check rate limit only if configured
424
- if (features.hasRateLimit) {
425
- const rateLimitInfo = await checkRateLimit(endpoint.rateLimit!, {
426
- header,
427
- services,
428
- logger,
429
- session,
430
- path: c.req.path,
431
- method: endpoint.method,
432
- });
433
-
434
- const rateLimitHeaders = getRateLimitHeaders(
435
- rateLimitInfo,
436
- endpoint.rateLimit!,
437
- );
438
- for (const [key, value] of Object.entries(rateLimitHeaders)) {
439
- if (value) {
440
- c.header(key, value);
441
- }
442
- }
443
- }
444
-
445
- // Create audit context only if audits are configured
446
- const auditContext = features.hasAudits
447
- ? await createAuditContext(
448
- endpoint as any,
449
- serviceDiscovery,
450
- logger,
451
- {
452
- session,
453
- header,
454
- cookie,
455
- services: services as Record<string, unknown>,
456
- },
457
- )
458
- : undefined;
459
-
460
- const audits = features.hasAudits
461
- ? (endpoint.audits as MappedAudit<TAuditAction, TOutSchema>[])
462
- : [];
463
-
464
- // Warn if declarative audits are configured but no audit storage
465
- if (features.hasAudits && !auditContext) {
466
- logger.warn('No auditor storage service available');
467
- }
468
-
469
- // Extract RLS context only if configured and not bypassed
470
- const rlsContext =
471
- features.hasRls && rawDb !== undefined
472
- ? await endpoint.rlsConfig?.extractor({
473
- services,
474
- session: session as TSession,
475
- header,
476
- cookie,
477
- logger,
478
- })
479
- : undefined;
480
-
481
- // Execute handler with automatic audit transaction support
482
- const result = await executeWithAuditTransaction(
483
- auditContext,
484
- async (auditor) => {
485
- const sameDatabase =
486
- auditContext?.storage?.databaseServiceName &&
487
- auditContext.storage.databaseServiceName ===
488
- endpoint.databaseService?.serviceName;
489
- const baseDb = sameDatabase
490
- ? (auditor?.getTransaction?.() ?? rawDb)
491
- : rawDb;
492
-
493
- const executeHandler = async (db: TDatabase | undefined) => {
494
- const responseBuilder = new ResponseBuilder();
495
- const response = await endpoint.handler(
496
- {
497
- services,
498
- logger,
499
- body: features.hasBodyValidation
500
- ? (c.req.valid as any)('json')
501
- : undefined,
502
- query: features.hasQueryValidation
503
- ? (c.req.valid as any)('query')
504
- : undefined,
505
- params: features.hasParamValidation
506
- ? (c.req.valid as any)('param')
507
- : undefined,
508
- session,
509
- header,
510
- cookie,
511
- auditor,
512
- db,
513
- } as unknown as EndpointContext<
514
- TInput,
515
- TServices,
516
- TLogger,
517
- TSession,
518
- TAuditAction,
519
- TDatabase,
520
- TAuditStorage
521
- >,
522
- responseBuilder,
523
- );
524
-
525
- let data = response;
526
- let metadata = responseBuilder.getMetadata();
527
-
528
- if (Endpoint.hasMetadata(response)) {
529
- data = response.data;
530
- metadata = response.metadata;
531
- }
532
-
533
- const output = endpoint.outputSchema
534
- ? await endpoint.parseOutput(data)
535
- : undefined;
536
-
537
- return { output, metadata, responseBuilder };
538
- };
539
-
540
- if (features.hasRls && rlsContext && baseDb) {
541
- return withRlsContext(
542
- baseDb as any,
543
- rlsContext,
544
- async (trx) => executeHandler(trx as TDatabase),
545
- { prefix: endpoint.rlsConfig?.prefix },
546
- );
547
- }
548
-
549
- return executeHandler(baseDb as TDatabase | undefined);
550
- },
551
- async (result, auditor) => {
552
- if (!audits?.length) return;
553
-
554
- for (const audit of audits) {
555
- if (audit.when && !audit.when(result.output as any)) {
556
- continue;
557
- }
558
- const payload = audit.payload(result.output as any);
559
- const entityId = audit.entityId?.(result.output as any);
560
- auditor.audit(audit.type as any, payload as any, {
561
- table: audit.table,
562
- entityId,
563
- });
564
- }
565
- },
566
- { db: rawDb },
567
- );
568
-
569
- const { output, metadata } = result;
570
-
571
- try {
572
- let status = endpoint.status as ContentfulStatusCode;
573
-
574
- if (metadata.status) {
575
- status = metadata.status as ContentfulStatusCode;
576
- }
577
-
578
- if (metadata.headers) {
579
- for (const [key, value] of Object.entries(metadata.headers)) {
580
- c.header(key, value);
581
- }
582
- }
583
-
584
- if (metadata.cookies) {
585
- for (const [name, { value, options }] of metadata.cookies) {
586
- setCookie(c, name, value, options);
587
- }
588
- }
589
-
590
- // Only publish events if configured (no global middleware overhead)
591
- if (features.hasEvents && Endpoint.isSuccessStatus(status)) {
592
- await publishConstructEvents<any, any>(
593
- endpoint as any,
594
- output,
595
- serviceDiscovery,
596
- logger,
597
- );
598
- }
599
-
600
- if (HonoEndpoint.isDev) {
601
- logger.info({ status, body: output }, 'Outgoing response');
602
- }
603
-
604
- // Respect the endpoint's declared responseType. For JSON (default)
605
- // we use c.json() which sets Content-Type and serializes. For any
606
- // other type, emit the body as-is and set the header explicitly —
607
- // metadata.headers (from r.header()) applied above still wins.
608
- if (endpoint.responseType === 'application/json') {
609
- // @ts-expect-error
610
- return c.json(output, status);
611
- }
612
- if (
613
- !(metadata.headers && hasContentTypeHeader(metadata.headers))
614
- ) {
615
- c.header('content-type', endpoint.responseType);
616
- }
617
- return c.body(output as any, status);
618
- } catch (validationError: any) {
619
- logger.error(validationError, 'Output validation failed');
620
- const error = wrapError(
621
- validationError,
622
- 422,
623
- 'Response validation failed',
624
- );
625
- if (HonoEndpoint.isDev) {
626
- logger.info(
627
- { status: error.statusCode, body: error },
628
- 'Outgoing response',
629
- );
630
- }
631
- return c.json(error, error.statusCode as ContentfulStatusCode);
632
- }
633
- } catch (e: any) {
634
- logger.error(e, 'Error processing endpoint request');
635
- const error = wrapError(e, 500, 'Internal Server Error');
636
- if (HonoEndpoint.isDev) {
637
- logger.info(
638
- { status: error.statusCode, body: error },
639
- 'Outgoing response',
640
- );
641
- }
642
- return c.json(error, error.statusCode as ContentfulStatusCode);
643
- }
644
- },
645
- );
646
- };
647
-
648
- // Register route with conditional validators
649
- app[method](route, ...validators, handler);
650
- }
651
-
652
- static addDocsRoute<
653
- TServices extends Service[] = [],
654
- TLogger extends Logger = Logger,
655
- >(
656
- endpoints: Endpoint<string, HttpMethod, any, any, TServices, TLogger>[],
657
- app: Hono,
658
- docsPath: string,
659
- openApiOptions?: HonoEndpointOptions['openApiOptions'],
660
- ): void {
661
- app.get(docsPath, async (c) => {
662
- try {
663
- const openApiSchema = await Endpoint.buildOpenApiSchema(
664
- endpoints,
665
- openApiOptions,
666
- );
667
-
668
- return c.json(openApiSchema);
669
- } catch {
670
- return c.json(
671
- { error: 'Failed to generate OpenAPI documentation' },
672
- 500,
673
- );
674
- }
675
- });
676
- }
677
- }