adorn-api 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (529) hide show
  1. package/README.md +51 -249
  2. package/dist/adapters/express/createApp.d.ts +20 -0
  3. package/dist/adapters/express/createApp.d.ts.map +1 -0
  4. package/dist/adapters/express/createApp.js +35 -0
  5. package/dist/adapters/express/createApp.js.map +1 -0
  6. package/dist/adapters/express/index.d.ts +7 -0
  7. package/dist/adapters/express/index.d.ts.map +1 -0
  8. package/dist/adapters/express/index.js +7 -0
  9. package/dist/adapters/express/index.js.map +1 -0
  10. package/dist/adapters/express/middleware/errorHandler.d.ts +3 -0
  11. package/dist/adapters/express/middleware/errorHandler.d.ts.map +1 -0
  12. package/dist/adapters/express/middleware/errorHandler.js +6 -0
  13. package/dist/adapters/express/middleware/errorHandler.js.map +1 -0
  14. package/dist/adapters/express/middleware/requestContext.d.ts +2 -0
  15. package/dist/adapters/express/middleware/requestContext.d.ts.map +1 -0
  16. package/dist/adapters/express/middleware/requestContext.js +3 -0
  17. package/dist/adapters/express/middleware/requestContext.js.map +1 -0
  18. package/dist/adapters/express/router.d.ts +10 -0
  19. package/dist/adapters/express/router.d.ts.map +1 -0
  20. package/dist/adapters/express/router.js +103 -0
  21. package/dist/adapters/express/router.js.map +1 -0
  22. package/dist/adapters/express/swagger/index.d.ts +2 -0
  23. package/dist/adapters/express/swagger/index.d.ts.map +1 -0
  24. package/dist/adapters/express/swagger/index.js +2 -0
  25. package/dist/adapters/express/swagger/index.js.map +1 -0
  26. package/dist/adapters/express/swagger/serve.d.ts +12 -0
  27. package/dist/adapters/express/swagger/serve.d.ts.map +1 -0
  28. package/dist/adapters/express/swagger/serve.js +72 -0
  29. package/dist/adapters/express/swagger/serve.js.map +1 -0
  30. package/dist/adapters/express/transport/request.d.ts +4 -0
  31. package/dist/adapters/express/transport/request.d.ts.map +1 -0
  32. package/dist/adapters/express/transport/request.js +12 -0
  33. package/dist/adapters/express/transport/request.js.map +1 -0
  34. package/dist/adapters/express/transport/response.d.ts +5 -0
  35. package/dist/adapters/express/transport/response.d.ts.map +1 -0
  36. package/dist/adapters/express/transport/response.js +36 -0
  37. package/dist/adapters/express/transport/response.js.map +1 -0
  38. package/dist/cli/commands/dev.d.ts +2 -0
  39. package/dist/cli/commands/dev.d.ts.map +1 -0
  40. package/dist/cli/commands/dev.js +3 -0
  41. package/dist/cli/commands/dev.js.map +1 -0
  42. package/dist/cli/commands/gen.d.ts +2 -0
  43. package/dist/cli/commands/gen.d.ts.map +1 -0
  44. package/dist/cli/commands/gen.js +3 -0
  45. package/dist/cli/commands/gen.js.map +1 -0
  46. package/dist/cli/main.d.ts +2 -0
  47. package/dist/cli/main.d.ts.map +1 -0
  48. package/dist/cli/main.js +3 -0
  49. package/dist/cli/main.js.map +1 -0
  50. package/dist/cli.d.ts +2 -0
  51. package/dist/cli.d.ts.map +1 -0
  52. package/dist/cli.js +3 -0
  53. package/dist/cli.js.map +1 -0
  54. package/dist/compiler/config/defaults.d.ts +2 -0
  55. package/dist/compiler/config/defaults.d.ts.map +1 -0
  56. package/dist/compiler/config/defaults.js +3 -0
  57. package/dist/compiler/config/defaults.js.map +1 -0
  58. package/dist/compiler/config/loadConfig.d.ts +2 -0
  59. package/dist/compiler/config/loadConfig.d.ts.map +1 -0
  60. package/dist/compiler/config/loadConfig.js +3 -0
  61. package/dist/compiler/config/loadConfig.js.map +1 -0
  62. package/dist/compiler/diagnostics/errors.d.ts +2 -0
  63. package/dist/compiler/diagnostics/errors.d.ts.map +1 -0
  64. package/dist/compiler/diagnostics/errors.js +3 -0
  65. package/dist/compiler/diagnostics/errors.js.map +1 -0
  66. package/dist/compiler/emit/openapi.d.ts +2 -0
  67. package/dist/compiler/emit/openapi.d.ts.map +1 -0
  68. package/dist/compiler/emit/openapi.js +3 -0
  69. package/dist/compiler/emit/openapi.js.map +1 -0
  70. package/dist/compiler/emit/routes.d.ts +2 -0
  71. package/dist/compiler/emit/routes.d.ts.map +1 -0
  72. package/dist/compiler/emit/routes.js +3 -0
  73. package/dist/compiler/emit/routes.js.map +1 -0
  74. package/dist/compiler/program/loadTsProgram.d.ts +2 -0
  75. package/dist/compiler/program/loadTsProgram.d.ts.map +1 -0
  76. package/dist/compiler/program/loadTsProgram.js +3 -0
  77. package/dist/compiler/program/loadTsProgram.js.map +1 -0
  78. package/dist/compiler/scan/actions.d.ts +2 -0
  79. package/dist/compiler/scan/actions.d.ts.map +1 -0
  80. package/dist/compiler/scan/actions.js +3 -0
  81. package/dist/compiler/scan/actions.js.map +1 -0
  82. package/dist/compiler/scan/controllers.d.ts +2 -0
  83. package/dist/compiler/scan/controllers.d.ts.map +1 -0
  84. package/dist/compiler/scan/controllers.js +3 -0
  85. package/dist/compiler/scan/controllers.js.map +1 -0
  86. package/dist/compiler/scan/types.d.ts +2 -0
  87. package/dist/compiler/scan/types.d.ts.map +1 -0
  88. package/dist/compiler/scan/types.js +3 -0
  89. package/dist/compiler/scan/types.js.map +1 -0
  90. package/dist/contracts/context.d.ts +10 -0
  91. package/dist/contracts/context.d.ts.map +1 -0
  92. package/dist/contracts/context.js +2 -0
  93. package/dist/contracts/context.js.map +1 -0
  94. package/dist/contracts/errors.d.ts +22 -0
  95. package/dist/contracts/errors.d.ts.map +1 -0
  96. package/dist/contracts/errors.js +2 -0
  97. package/dist/contracts/errors.js.map +1 -0
  98. package/dist/contracts/http.d.ts +2 -0
  99. package/dist/contracts/http.d.ts.map +1 -0
  100. package/dist/contracts/http.js +3 -0
  101. package/dist/contracts/http.js.map +1 -0
  102. package/dist/contracts/middleware.d.ts +2 -0
  103. package/dist/contracts/middleware.d.ts.map +1 -0
  104. package/dist/contracts/middleware.js +3 -0
  105. package/dist/contracts/middleware.js.map +1 -0
  106. package/dist/contracts/openapi-v3.d.ts +77 -0
  107. package/dist/contracts/openapi-v3.d.ts.map +1 -0
  108. package/dist/contracts/openapi-v3.js +2 -0
  109. package/dist/contracts/openapi-v3.js.map +1 -0
  110. package/dist/contracts/openapi.d.ts +2 -0
  111. package/dist/contracts/openapi.d.ts.map +1 -0
  112. package/dist/contracts/openapi.js +2 -0
  113. package/dist/contracts/openapi.js.map +1 -0
  114. package/dist/contracts/reply.d.ts +11 -0
  115. package/dist/contracts/reply.d.ts.map +1 -0
  116. package/dist/contracts/reply.js +4 -0
  117. package/dist/contracts/reply.js.map +1 -0
  118. package/dist/contracts/response-types.d.ts +40 -0
  119. package/dist/contracts/response-types.d.ts.map +1 -0
  120. package/dist/contracts/response-types.js +2 -0
  121. package/dist/contracts/response-types.js.map +1 -0
  122. package/dist/contracts/responses.d.ts +18 -0
  123. package/dist/contracts/responses.d.ts.map +1 -0
  124. package/dist/contracts/responses.js +2 -0
  125. package/dist/contracts/responses.js.map +1 -0
  126. package/dist/contracts/route-options.d.ts +24 -0
  127. package/dist/contracts/route-options.d.ts.map +1 -0
  128. package/dist/contracts/route-options.js +2 -0
  129. package/dist/contracts/route-options.js.map +1 -0
  130. package/dist/contracts/route-typing.d.ts +25 -0
  131. package/dist/contracts/route-typing.d.ts.map +1 -0
  132. package/dist/contracts/route-typing.js +2 -0
  133. package/dist/contracts/route-typing.js.map +1 -0
  134. package/dist/contracts/validator.d.ts +25 -0
  135. package/dist/contracts/validator.d.ts.map +1 -0
  136. package/dist/contracts/validator.js +2 -0
  137. package/dist/contracts/validator.js.map +1 -0
  138. package/dist/core/binding/binder.d.ts +19 -0
  139. package/dist/core/binding/binder.d.ts.map +1 -0
  140. package/dist/core/binding/binder.js +128 -0
  141. package/dist/core/binding/binder.js.map +1 -0
  142. package/dist/core/binding/coerce/arrays.d.ts +7 -0
  143. package/dist/core/binding/coerce/arrays.d.ts.map +1 -0
  144. package/dist/core/binding/coerce/arrays.js +28 -0
  145. package/dist/core/binding/coerce/arrays.js.map +1 -0
  146. package/dist/core/binding/coerce/csv.d.ts +2 -0
  147. package/dist/core/binding/coerce/csv.d.ts.map +1 -0
  148. package/dist/core/binding/coerce/csv.js +7 -0
  149. package/dist/core/binding/coerce/csv.js.map +1 -0
  150. package/dist/core/binding/coerce/objects.d.ts +2 -0
  151. package/dist/core/binding/coerce/objects.d.ts.map +1 -0
  152. package/dist/core/binding/coerce/objects.js +3 -0
  153. package/dist/core/binding/coerce/objects.js.map +1 -0
  154. package/dist/core/binding/coerce/primitives.d.ts +3 -0
  155. package/dist/core/binding/coerce/primitives.d.ts.map +1 -0
  156. package/dist/core/binding/coerce/primitives.js +18 -0
  157. package/dist/core/binding/coerce/primitives.js.map +1 -0
  158. package/dist/core/binding/index.d.ts +2 -0
  159. package/dist/core/binding/index.d.ts.map +1 -0
  160. package/dist/core/binding/index.js +2 -0
  161. package/dist/core/binding/index.js.map +1 -0
  162. package/dist/core/binding/rules/inferFromHttpMethod.d.ts +6 -0
  163. package/dist/core/binding/rules/inferFromHttpMethod.d.ts.map +1 -0
  164. package/dist/core/binding/rules/inferFromHttpMethod.js +11 -0
  165. package/dist/core/binding/rules/inferFromHttpMethod.js.map +1 -0
  166. package/dist/core/binding/rules/inferFromPath.d.ts +2 -0
  167. package/dist/core/binding/rules/inferFromPath.d.ts.map +1 -0
  168. package/dist/core/binding/rules/inferFromPath.js +9 -0
  169. package/dist/core/binding/rules/inferFromPath.js.map +1 -0
  170. package/dist/core/binding/rules/wrappers.d.ts +2 -0
  171. package/dist/core/binding/rules/wrappers.d.ts.map +1 -0
  172. package/dist/core/binding/rules/wrappers.js +3 -0
  173. package/dist/core/binding/rules/wrappers.js.map +1 -0
  174. package/dist/core/errors/http-error.d.ts +9 -0
  175. package/dist/core/errors/http-error.d.ts.map +1 -0
  176. package/dist/core/errors/http-error.js +17 -0
  177. package/dist/core/errors/http-error.js.map +1 -0
  178. package/dist/core/errors/index.d.ts +4 -0
  179. package/dist/core/errors/index.d.ts.map +1 -0
  180. package/dist/core/errors/index.js +4 -0
  181. package/dist/core/errors/index.js.map +1 -0
  182. package/dist/core/errors/problem.d.ts +3 -0
  183. package/dist/core/errors/problem.d.ts.map +1 -0
  184. package/dist/core/errors/problem.js +33 -0
  185. package/dist/core/errors/problem.js.map +1 -0
  186. package/dist/core/errors/validation-error.d.ts +8 -0
  187. package/dist/core/errors/validation-error.d.ts.map +1 -0
  188. package/dist/core/errors/validation-error.js +17 -0
  189. package/dist/core/errors/validation-error.js.map +1 -0
  190. package/dist/core/openapi/buildOpenApi.d.ts +14 -0
  191. package/dist/core/openapi/buildOpenApi.d.ts.map +1 -0
  192. package/dist/core/openapi/buildOpenApi.js +134 -0
  193. package/dist/core/openapi/buildOpenApi.js.map +1 -0
  194. package/dist/core/openapi/index.d.ts +2 -0
  195. package/dist/core/openapi/index.d.ts.map +1 -0
  196. package/dist/core/openapi/index.js +2 -0
  197. package/dist/core/openapi/index.js.map +1 -0
  198. package/dist/core/openapi/schema/formats.d.ts +2 -0
  199. package/dist/core/openapi/schema/formats.d.ts.map +1 -0
  200. package/dist/core/openapi/schema/formats.js +3 -0
  201. package/dist/core/openapi/schema/formats.js.map +1 -0
  202. package/dist/core/openapi/schema/registry.d.ts +9 -0
  203. package/dist/core/openapi/schema/registry.d.ts.map +1 -0
  204. package/dist/core/openapi/schema/registry.js +21 -0
  205. package/dist/core/openapi/schema/registry.js.map +1 -0
  206. package/dist/core/openapi/schema/schemaModel.d.ts +2 -0
  207. package/dist/core/openapi/schema/schemaModel.d.ts.map +1 -0
  208. package/dist/core/openapi/schema/schemaModel.js +3 -0
  209. package/dist/core/openapi/schema/schemaModel.js.map +1 -0
  210. package/dist/core/openapi/schema/schemaRegistry.d.ts +2 -0
  211. package/dist/core/openapi/schema/schemaRegistry.d.ts.map +1 -0
  212. package/dist/core/openapi/schema/schemaRegistry.js +3 -0
  213. package/dist/core/openapi/schema/schemaRegistry.js.map +1 -0
  214. package/dist/core/openapi/schema/toOpenApi.d.ts +4 -0
  215. package/dist/core/openapi/schema/toOpenApi.d.ts.map +1 -0
  216. package/dist/core/openapi/schema/toOpenApi.js +82 -0
  217. package/dist/core/openapi/schema/toOpenApi.js.map +1 -0
  218. package/dist/core/pipeline/compose.d.ts +2 -0
  219. package/dist/core/pipeline/compose.d.ts.map +1 -0
  220. package/dist/core/pipeline/compose.js +3 -0
  221. package/dist/core/pipeline/compose.js.map +1 -0
  222. package/dist/core/pipeline/errorMap.d.ts +2 -0
  223. package/dist/core/pipeline/errorMap.d.ts.map +1 -0
  224. package/dist/core/pipeline/errorMap.js +3 -0
  225. package/dist/core/pipeline/errorMap.js.map +1 -0
  226. package/dist/core/pipeline/invoke.d.ts +2 -0
  227. package/dist/core/pipeline/invoke.d.ts.map +1 -0
  228. package/dist/core/pipeline/invoke.js +3 -0
  229. package/dist/core/pipeline/invoke.js.map +1 -0
  230. package/dist/core/pipeline/result.d.ts +2 -0
  231. package/dist/core/pipeline/result.d.ts.map +1 -0
  232. package/dist/core/pipeline/result.js +3 -0
  233. package/dist/core/pipeline/result.js.map +1 -0
  234. package/dist/core/registry/buildRegistry.d.ts +3 -0
  235. package/dist/core/registry/buildRegistry.d.ts.map +1 -0
  236. package/dist/core/registry/buildRegistry.js +61 -0
  237. package/dist/core/registry/buildRegistry.js.map +1 -0
  238. package/dist/core/registry/conflicts.d.ts +6 -0
  239. package/dist/core/registry/conflicts.d.ts.map +1 -0
  240. package/dist/core/registry/conflicts.js +21 -0
  241. package/dist/core/registry/conflicts.js.map +1 -0
  242. package/dist/core/registry/index.d.ts +5 -0
  243. package/dist/core/registry/index.d.ts.map +1 -0
  244. package/dist/core/registry/index.js +5 -0
  245. package/dist/core/registry/index.js.map +1 -0
  246. package/dist/core/registry/normalize.d.ts +3 -0
  247. package/dist/core/registry/normalize.d.ts.map +1 -0
  248. package/dist/core/registry/normalize.js +24 -0
  249. package/dist/core/registry/normalize.js.map +1 -0
  250. package/dist/core/registry/types.d.ts +32 -0
  251. package/dist/core/registry/types.d.ts.map +1 -0
  252. package/dist/core/registry/types.js +2 -0
  253. package/dist/core/registry/types.js.map +1 -0
  254. package/dist/core/reply/index.d.ts +3 -0
  255. package/dist/core/reply/index.d.ts.map +1 -0
  256. package/dist/core/reply/index.js +3 -0
  257. package/dist/core/reply/index.js.map +1 -0
  258. package/dist/core/reply/reply.d.ts +8 -0
  259. package/dist/core/reply/reply.d.ts.map +1 -0
  260. package/dist/core/reply/reply.js +18 -0
  261. package/dist/core/reply/reply.js.map +1 -0
  262. package/dist/core/reply/typed.d.ts +27 -0
  263. package/dist/core/reply/typed.d.ts.map +1 -0
  264. package/dist/core/reply/typed.js +19 -0
  265. package/dist/core/reply/typed.js.map +1 -0
  266. package/dist/core/responses/helpers.d.ts +10 -0
  267. package/dist/core/responses/helpers.d.ts.map +1 -0
  268. package/dist/core/responses/helpers.js +8 -0
  269. package/dist/core/responses/helpers.js.map +1 -0
  270. package/dist/core/responses/index.d.ts +4 -0
  271. package/dist/core/responses/index.d.ts.map +1 -0
  272. package/dist/core/responses/index.js +4 -0
  273. package/dist/core/responses/index.js.map +1 -0
  274. package/dist/core/responses/normalize.d.ts +3 -0
  275. package/dist/core/responses/normalize.d.ts.map +1 -0
  276. package/dist/core/responses/normalize.js +32 -0
  277. package/dist/core/responses/normalize.js.map +1 -0
  278. package/dist/core/responses/pickStatus.d.ts +3 -0
  279. package/dist/core/responses/pickStatus.d.ts.map +1 -0
  280. package/dist/core/responses/pickStatus.js +27 -0
  281. package/dist/core/responses/pickStatus.js.map +1 -0
  282. package/dist/core/route/defineRoute.d.ts +27 -0
  283. package/dist/core/route/defineRoute.d.ts.map +1 -0
  284. package/dist/core/route/defineRoute.js +18 -0
  285. package/dist/core/route/defineRoute.js.map +1 -0
  286. package/dist/core/route/index.d.ts +2 -0
  287. package/dist/core/route/index.d.ts.map +1 -0
  288. package/dist/core/route/index.js +2 -0
  289. package/dist/core/route/index.js.map +1 -0
  290. package/dist/core/serialization/json.d.ts +2 -0
  291. package/dist/core/serialization/json.d.ts.map +1 -0
  292. package/dist/core/serialization/json.js +3 -0
  293. package/dist/core/serialization/json.js.map +1 -0
  294. package/dist/core/typing/path-params.d.ts +2 -0
  295. package/dist/core/typing/path-params.d.ts.map +1 -0
  296. package/dist/core/typing/path-params.js +2 -0
  297. package/dist/core/typing/path-params.js.map +1 -0
  298. package/dist/decorators/binding.d.ts +9 -0
  299. package/dist/decorators/binding.d.ts.map +1 -0
  300. package/dist/decorators/binding.js +18 -0
  301. package/dist/decorators/binding.js.map +1 -0
  302. package/dist/decorators/controller.d.ts +6 -0
  303. package/dist/decorators/controller.d.ts.map +1 -0
  304. package/dist/decorators/controller.js +26 -0
  305. package/dist/decorators/controller.js.map +1 -0
  306. package/dist/decorators/db.d.ts +2 -0
  307. package/dist/decorators/db.d.ts.map +1 -0
  308. package/dist/decorators/db.js +3 -0
  309. package/dist/decorators/db.js.map +1 -0
  310. package/dist/decorators/docs.d.ts +2 -0
  311. package/dist/decorators/docs.d.ts.map +1 -0
  312. package/dist/decorators/docs.js +3 -0
  313. package/dist/decorators/docs.js.map +1 -0
  314. package/dist/decorators/index.d.ts +4 -0
  315. package/dist/decorators/index.d.ts.map +1 -0
  316. package/dist/decorators/index.js +4 -0
  317. package/dist/decorators/index.js.map +1 -0
  318. package/dist/decorators/methods.d.ts +24 -0
  319. package/dist/decorators/methods.d.ts.map +1 -0
  320. package/dist/decorators/methods.js +46 -0
  321. package/dist/decorators/methods.js.map +1 -0
  322. package/dist/decorators/middleware.d.ts +2 -0
  323. package/dist/decorators/middleware.d.ts.map +1 -0
  324. package/dist/decorators/middleware.js +3 -0
  325. package/dist/decorators/middleware.js.map +1 -0
  326. package/dist/decorators/responses.d.ts +2 -0
  327. package/dist/decorators/responses.d.ts.map +1 -0
  328. package/dist/decorators/responses.js +3 -0
  329. package/dist/decorators/responses.js.map +1 -0
  330. package/dist/decorators/security.d.ts +2 -0
  331. package/dist/decorators/security.d.ts.map +1 -0
  332. package/dist/decorators/security.js +3 -0
  333. package/dist/decorators/security.js.map +1 -0
  334. package/dist/express.d.ts +2 -0
  335. package/dist/express.d.ts.map +1 -0
  336. package/dist/express.js +2 -0
  337. package/dist/express.js.map +1 -0
  338. package/dist/index.d.ts +12 -0
  339. package/dist/index.d.ts.map +1 -0
  340. package/dist/index.js +12 -2
  341. package/dist/index.js.map +1 -0
  342. package/dist/integrations/metal-orm/index.d.ts +2 -0
  343. package/dist/integrations/metal-orm/index.d.ts.map +1 -0
  344. package/dist/integrations/metal-orm/index.js +2 -0
  345. package/dist/integrations/metal-orm/index.js.map +1 -0
  346. package/dist/integrations/metal-orm/pagination/executePaged.d.ts +2 -0
  347. package/dist/integrations/metal-orm/pagination/executePaged.d.ts.map +1 -0
  348. package/dist/integrations/metal-orm/pagination/executePaged.js +3 -0
  349. package/dist/integrations/metal-orm/pagination/executePaged.js.map +1 -0
  350. package/dist/integrations/metal-orm/pagination/page.d.ts +2 -0
  351. package/dist/integrations/metal-orm/pagination/page.d.ts.map +1 -0
  352. package/dist/integrations/metal-orm/pagination/page.js +3 -0
  353. package/dist/integrations/metal-orm/pagination/page.js.map +1 -0
  354. package/dist/integrations/metal-orm/query/filters.d.ts +2 -0
  355. package/dist/integrations/metal-orm/query/filters.d.ts.map +1 -0
  356. package/dist/integrations/metal-orm/query/filters.js +3 -0
  357. package/dist/integrations/metal-orm/query/filters.js.map +1 -0
  358. package/dist/integrations/metal-orm/query/search.d.ts +2 -0
  359. package/dist/integrations/metal-orm/query/search.d.ts.map +1 -0
  360. package/dist/integrations/metal-orm/query/search.js +3 -0
  361. package/dist/integrations/metal-orm/query/search.js.map +1 -0
  362. package/dist/integrations/metal-orm/query/sort.d.ts +2 -0
  363. package/dist/integrations/metal-orm/query/sort.d.ts.map +1 -0
  364. package/dist/integrations/metal-orm/query/sort.js +3 -0
  365. package/dist/integrations/metal-orm/query/sort.js.map +1 -0
  366. package/dist/integrations/metal-orm/save-graph/helpers.d.ts +2 -0
  367. package/dist/integrations/metal-orm/save-graph/helpers.d.ts.map +1 -0
  368. package/dist/integrations/metal-orm/save-graph/helpers.js +3 -0
  369. package/dist/integrations/metal-orm/save-graph/helpers.js.map +1 -0
  370. package/dist/integrations/metal-orm/save-graph/types.d.ts +2 -0
  371. package/dist/integrations/metal-orm/save-graph/types.d.ts.map +1 -0
  372. package/dist/integrations/metal-orm/save-graph/types.js +3 -0
  373. package/dist/integrations/metal-orm/save-graph/types.js.map +1 -0
  374. package/dist/integrations/metal-orm/schema/column-map.d.ts +5 -0
  375. package/dist/integrations/metal-orm/schema/column-map.d.ts.map +1 -0
  376. package/dist/integrations/metal-orm/schema/column-map.js +80 -0
  377. package/dist/integrations/metal-orm/schema/column-map.js.map +1 -0
  378. package/dist/integrations/metal-orm/schema/ddl.d.ts +2 -0
  379. package/dist/integrations/metal-orm/schema/ddl.d.ts.map +1 -0
  380. package/dist/integrations/metal-orm/schema/ddl.js +3 -0
  381. package/dist/integrations/metal-orm/schema/ddl.js.map +1 -0
  382. package/dist/integrations/metal-orm/schema/dto.d.ts +7 -0
  383. package/dist/integrations/metal-orm/schema/dto.d.ts.map +1 -0
  384. package/dist/integrations/metal-orm/schema/dto.js +34 -0
  385. package/dist/integrations/metal-orm/schema/dto.js.map +1 -0
  386. package/dist/integrations/metal-orm/schema/entity.d.ts +17 -0
  387. package/dist/integrations/metal-orm/schema/entity.d.ts.map +1 -0
  388. package/dist/integrations/metal-orm/schema/entity.js +27 -0
  389. package/dist/integrations/metal-orm/schema/entity.js.map +1 -0
  390. package/dist/integrations/metal-orm/schema/filters.d.ts +11 -0
  391. package/dist/integrations/metal-orm/schema/filters.d.ts.map +1 -0
  392. package/dist/integrations/metal-orm/schema/filters.js +20 -0
  393. package/dist/integrations/metal-orm/schema/filters.js.map +1 -0
  394. package/dist/integrations/metal-orm/schema/index.d.ts +5 -0
  395. package/dist/integrations/metal-orm/schema/index.d.ts.map +1 -0
  396. package/dist/integrations/metal-orm/schema/index.js +5 -0
  397. package/dist/integrations/metal-orm/schema/index.js.map +1 -0
  398. package/dist/integrations/metal-orm/schema/openapi/entityToSchema.d.ts +2 -0
  399. package/dist/integrations/metal-orm/schema/openapi/entityToSchema.d.ts.map +1 -0
  400. package/dist/integrations/metal-orm/schema/openapi/entityToSchema.js +3 -0
  401. package/dist/integrations/metal-orm/schema/openapi/entityToSchema.js.map +1 -0
  402. package/dist/integrations/metal-orm/schema/openapi/tableDefToSchema.d.ts +2 -0
  403. package/dist/integrations/metal-orm/schema/openapi/tableDefToSchema.d.ts.map +1 -0
  404. package/dist/integrations/metal-orm/schema/openapi/tableDefToSchema.js +3 -0
  405. package/dist/integrations/metal-orm/schema/openapi/tableDefToSchema.js.map +1 -0
  406. package/dist/integrations/metal-orm/schema/sqlite.d.ts +2 -0
  407. package/dist/integrations/metal-orm/schema/sqlite.d.ts.map +1 -0
  408. package/dist/integrations/metal-orm/schema/sqlite.js +3 -0
  409. package/dist/integrations/metal-orm/schema/sqlite.js.map +1 -0
  410. package/dist/integrations/metal-orm/schema/tabledef.d.ts +4 -0
  411. package/dist/integrations/metal-orm/schema/tabledef.d.ts.map +1 -0
  412. package/dist/integrations/metal-orm/schema/tabledef.js +10 -0
  413. package/dist/integrations/metal-orm/schema/tabledef.js.map +1 -0
  414. package/dist/integrations/metal-orm/schema/types.d.ts +7 -0
  415. package/dist/integrations/metal-orm/schema/types.d.ts.map +1 -0
  416. package/dist/integrations/metal-orm/schema/types.js +2 -0
  417. package/dist/integrations/metal-orm/schema/types.js.map +1 -0
  418. package/dist/integrations/metal-orm/serialization/entitySerializer.d.ts +2 -0
  419. package/dist/integrations/metal-orm/serialization/entitySerializer.d.ts.map +1 -0
  420. package/dist/integrations/metal-orm/serialization/entitySerializer.js +3 -0
  421. package/dist/integrations/metal-orm/serialization/entitySerializer.js.map +1 -0
  422. package/dist/integrations/metal-orm/serialization/relationPolicy.d.ts +2 -0
  423. package/dist/integrations/metal-orm/serialization/relationPolicy.d.ts.map +1 -0
  424. package/dist/integrations/metal-orm/serialization/relationPolicy.js +3 -0
  425. package/dist/integrations/metal-orm/serialization/relationPolicy.js.map +1 -0
  426. package/dist/integrations/metal-orm/session/context.d.ts +2 -0
  427. package/dist/integrations/metal-orm/session/context.d.ts.map +1 -0
  428. package/dist/integrations/metal-orm/session/context.js +3 -0
  429. package/dist/integrations/metal-orm/session/context.js.map +1 -0
  430. package/dist/integrations/metal-orm/session/middleware.d.ts +2 -0
  431. package/dist/integrations/metal-orm/session/middleware.d.ts.map +1 -0
  432. package/dist/integrations/metal-orm/session/middleware.js +3 -0
  433. package/dist/integrations/metal-orm/session/middleware.js.map +1 -0
  434. package/dist/integrations/metal-orm/session/transaction.d.ts +2 -0
  435. package/dist/integrations/metal-orm/session/transaction.d.ts.map +1 -0
  436. package/dist/integrations/metal-orm/session/transaction.js +3 -0
  437. package/dist/integrations/metal-orm/session/transaction.js.map +1 -0
  438. package/dist/integrations/metal-orm/testing/setupSchema.d.ts +2 -0
  439. package/dist/integrations/metal-orm/testing/setupSchema.d.ts.map +1 -0
  440. package/dist/integrations/metal-orm/testing/setupSchema.js +3 -0
  441. package/dist/integrations/metal-orm/testing/setupSchema.js.map +1 -0
  442. package/dist/integrations/metal-orm/testing/sqliteMemory.d.ts +2 -0
  443. package/dist/integrations/metal-orm/testing/sqliteMemory.d.ts.map +1 -0
  444. package/dist/integrations/metal-orm/testing/sqliteMemory.js +3 -0
  445. package/dist/integrations/metal-orm/testing/sqliteMemory.js.map +1 -0
  446. package/dist/metadata/bag.d.ts +17 -0
  447. package/dist/metadata/bag.d.ts.map +1 -0
  448. package/dist/metadata/bag.js +38 -0
  449. package/dist/metadata/bag.js.map +1 -0
  450. package/dist/metadata/index.d.ts +4 -0
  451. package/dist/metadata/index.d.ts.map +1 -0
  452. package/dist/metadata/index.js +4 -0
  453. package/dist/metadata/index.js.map +1 -0
  454. package/dist/metadata/keys.d.ts +52 -0
  455. package/dist/metadata/keys.d.ts.map +1 -0
  456. package/dist/metadata/keys.js +29 -0
  457. package/dist/metadata/keys.js.map +1 -0
  458. package/dist/metadata/merge.d.ts +9 -0
  459. package/dist/metadata/merge.d.ts.map +1 -0
  460. package/dist/metadata/merge.js +27 -0
  461. package/dist/metadata/merge.js.map +1 -0
  462. package/dist/metal-orm.d.ts +2 -0
  463. package/dist/metal-orm.d.ts.map +1 -0
  464. package/dist/metal-orm.js +2 -0
  465. package/dist/metal-orm.js.map +1 -0
  466. package/dist/validation/native/index.d.ts +3 -0
  467. package/dist/validation/native/index.d.ts.map +1 -0
  468. package/dist/validation/native/index.js +3 -0
  469. package/dist/validation/native/index.js.map +1 -0
  470. package/dist/validation/native/ir.d.ts +38 -0
  471. package/dist/validation/native/ir.d.ts.map +1 -0
  472. package/dist/validation/native/ir.js +2 -0
  473. package/dist/validation/native/ir.js.map +1 -0
  474. package/dist/validation/native/schema.d.ts +63 -0
  475. package/dist/validation/native/schema.d.ts.map +1 -0
  476. package/dist/validation/native/schema.js +271 -0
  477. package/dist/validation/native/schema.js.map +1 -0
  478. package/dist/validation/native/validator.d.ts +21 -0
  479. package/dist/validation/native/validator.d.ts.map +1 -0
  480. package/dist/validation/native/validator.js +48 -0
  481. package/dist/validation/native/validator.js.map +1 -0
  482. package/package.json +53 -34
  483. package/dist/cli/generate-routes.js +0 -101
  484. package/dist/cli/generate-swagger.js +0 -197
  485. package/dist/controllers/advanced.controller.js +0 -131
  486. package/dist/controllers/user.controller.js +0 -121
  487. package/dist/entities/user.entity.js +0 -1
  488. package/dist/lib/common.js +0 -62
  489. package/dist/lib/decorators.js +0 -116
  490. package/dist/middleware/auth.middleware.js +0 -13
  491. package/dist/routes.js +0 -80
  492. package/dist/server.js +0 -18
  493. package/dist/src/cli/generate-routes.js +0 -105
  494. package/dist/src/cli/generate-swagger.js +0 -197
  495. package/dist/src/index.js +0 -4
  496. package/dist/src/lib/common.js +0 -62
  497. package/dist/src/lib/decorators.js +0 -116
  498. package/dist/src/routes.js +0 -80
  499. package/dist/src/server.js +0 -18
  500. package/dist/tests/example-app/controllers/advanced.controller.js +0 -130
  501. package/dist/tests/example-app/controllers/controllers/advanced.controller.js +0 -131
  502. package/dist/tests/example-app/controllers/controllers/user.controller.js +0 -121
  503. package/dist/tests/example-app/controllers/user.controller.js +0 -121
  504. package/dist/tests/example-app/entities/entities/user.entity.js +0 -1
  505. package/dist/tests/example-app/entities/user.entity.js +0 -1
  506. package/dist/tests/example-app/middleware/auth.middleware.js +0 -13
  507. package/dist/tests/example-app/middleware/middleware/auth.middleware.js +0 -13
  508. package/dist/tests/example-app/routes.js +0 -80
  509. package/dist/tests/example-app/server.js +0 -23
  510. package/scripts/run-example.js +0 -32
  511. package/src/cli/generate-routes.ts +0 -123
  512. package/src/cli/generate-swagger.ts +0 -216
  513. package/src/index.js +0 -20
  514. package/src/index.ts +0 -4
  515. package/src/lib/common.js +0 -68
  516. package/src/lib/common.ts +0 -35
  517. package/src/lib/decorators.js +0 -128
  518. package/src/lib/decorators.ts +0 -136
  519. package/swagger.json +0 -238
  520. package/tests/e2e.test.ts +0 -72
  521. package/tests/example-app/controllers/advanced.controller.ts +0 -52
  522. package/tests/example-app/controllers/user.controller.ts +0 -35
  523. package/tests/example-app/entities/user.entity.ts +0 -8
  524. package/tests/example-app/middleware/auth.middleware.ts +0 -16
  525. package/tests/example-app/routes.ts +0 -102
  526. package/tests/example-app/server.ts +0 -30
  527. package/tests/generators.test.ts +0 -48
  528. package/tests/utils.ts +0 -46
  529. package/tsconfig.json +0 -20
@@ -1,136 +0,0 @@
1
- // src/lib/decorators.ts
2
-
3
- // 1. HTTP Methods
4
- export type HttpMethod = 'get' | 'post' | 'put' | 'delete';
5
-
6
- // Context metadata symbol for standard decorators
7
- const META_KEY = Symbol('adorn:route');
8
- export const SCHEMA_META = Symbol('adorn:schema');
9
- export const AUTH_META = Symbol('adorn:auth');
10
-
11
- export interface RouteDefinition {
12
- method: HttpMethod;
13
- path: string;
14
- methodName: string;
15
- }
16
-
17
- // -- Method Decorator --
18
- // Using Standard TC39 Signature
19
- export function Get(path: string) {
20
- return function (originalMethod: any, context: ClassMethodDecoratorContext) {
21
- // In standard decorators, we can attach metadata to the class prototype via context
22
- context.addInitializer(function () {
23
- const routes: RouteDefinition[] = (this as any)[META_KEY] || [];
24
- routes.push({
25
- method: 'get',
26
- path,
27
- methodName: String(context.name),
28
- });
29
- (this as any)[META_KEY] = routes;
30
- });
31
- return originalMethod;
32
- };
33
- }
34
-
35
- export function Post(path: string) {
36
- return function (originalMethod: any, context: ClassMethodDecoratorContext) {
37
- context.addInitializer(function () {
38
- const routes: RouteDefinition[] = (this as any)[META_KEY] || [];
39
- routes.push({
40
- method: 'post',
41
- path,
42
- methodName: String(context.name),
43
- });
44
- (this as any)[META_KEY] = routes;
45
- });
46
- return originalMethod;
47
- };
48
- }
49
-
50
- export function Put(path: string) {
51
- return function (originalMethod: any, context: ClassMethodDecoratorContext) {
52
- context.addInitializer(function () {
53
- const routes: RouteDefinition[] = (this as any)[META_KEY] || [];
54
- routes.push({
55
- method: 'put',
56
- path,
57
- methodName: String(context.name),
58
- });
59
- (this as any)[META_KEY] = routes;
60
- });
61
- return originalMethod;
62
- };
63
- }
64
-
65
- export function Delete(path: string) {
66
- return function (originalMethod: any, context: ClassMethodDecoratorContext) {
67
- context.addInitializer(function () {
68
- const routes: RouteDefinition[] = (this as any)[META_KEY] || [];
69
- routes.push({
70
- method: 'delete',
71
- path,
72
- methodName: String(context.name),
73
- });
74
- (this as any)[META_KEY] = routes;
75
- });
76
- return originalMethod;
77
- };
78
- }
79
-
80
- // -- Class Decorator --
81
- export function Controller(basePath: string) {
82
- return function (target: any, context: ClassDecoratorContext) {
83
- // We attach the base path to the class constructor
84
- context.addInitializer(function () {
85
- (this as any)._basePath = basePath;
86
- });
87
- return target;
88
- };
89
- }
90
-
91
- // -- DTO Field Decorators --
92
- // Since we can't decorate parameters, we decorate fields in a class
93
- // e.g. class GetUserParams { @FromPath id: string }
94
-
95
- export function FromQuery(name?: string) {
96
- return function (target: undefined, context: ClassFieldDecoratorContext) {
97
- context.addInitializer(function () {
98
- const meta = (this as any)[SCHEMA_META] || {};
99
- meta[context.name] = { type: 'query' };
100
- (this as any)[SCHEMA_META] = meta;
101
- });
102
- return function (initialValue: any) { return initialValue; };
103
- };
104
- }
105
-
106
- export function FromPath(name?: string) {
107
- return function (target: undefined, context: ClassFieldDecoratorContext) {
108
- context.addInitializer(function () {
109
- const meta = (this as any)[SCHEMA_META] || {};
110
- meta[context.name] = { type: 'path' };
111
- (this as any)[SCHEMA_META] = meta;
112
- });
113
- return function (initialValue: any) { return initialValue; };
114
- };
115
- }
116
-
117
- export function FromBody() {
118
- return function (target: undefined, context: ClassFieldDecoratorContext) {
119
- context.addInitializer(function () {
120
- const meta = (this as any)[SCHEMA_META] || {};
121
- meta[context.name] = { type: 'body' };
122
- (this as any)[SCHEMA_META] = meta;
123
- });
124
- return function (initialValue: any) { return initialValue; };
125
- };
126
- }
127
-
128
- // -- Authentication Decorator --
129
- export function Authorized(role?: string) {
130
- return function (target: any, context: ClassMethodDecoratorContext | ClassDecoratorContext) {
131
- context.addInitializer(function () {
132
- (this as any)[AUTH_META] = role || 'default';
133
- });
134
- return target;
135
- };
136
- }
package/swagger.json DELETED
@@ -1,238 +0,0 @@
1
- {
2
- "openapi": "3.0.0",
3
- "info": {
4
- "title": "Adorn API",
5
- "version": "2.0.0"
6
- },
7
- "paths": {
8
- "/advanced/{tenantId}/users": {
9
- "get": {
10
- "operationId": "listUsers",
11
- "parameters": [
12
- {
13
- "name": "search",
14
- "in": "query",
15
- "required": false,
16
- "schema": {
17
- "type": "string"
18
- }
19
- },
20
- {
21
- "name": "tenantId",
22
- "in": "path",
23
- "required": true,
24
- "schema": {
25
- "type": "string"
26
- }
27
- },
28
- {
29
- "name": "page",
30
- "in": "query",
31
- "required": true,
32
- "schema": {
33
- "type": "integer"
34
- }
35
- },
36
- {
37
- "name": "limit",
38
- "in": "query",
39
- "required": true,
40
- "schema": {
41
- "type": "integer"
42
- }
43
- }
44
- ],
45
- "responses": {
46
- "200": {
47
- "description": "Success",
48
- "content": {
49
- "application/json": {
50
- "schema": {
51
- "type": "array",
52
- "items": {
53
- "type": "object",
54
- "properties": {
55
- "id": {
56
- "type": "string"
57
- },
58
- "name": {
59
- "type": "string"
60
- },
61
- "email": {
62
- "type": "string"
63
- },
64
- "isActive": {
65
- "type": "boolean"
66
- },
67
- "createdAt": {
68
- "type": "string"
69
- }
70
- },
71
- "required": [
72
- "id",
73
- "name",
74
- "email",
75
- "isActive",
76
- "createdAt"
77
- ]
78
- }
79
- }
80
- }
81
- }
82
- }
83
- }
84
- }
85
- },
86
- "/advanced/": {
87
- "post": {
88
- "operationId": "create",
89
- "parameters": [],
90
- "requestBody": {
91
- "content": {
92
- "application/json": {
93
- "schema": {
94
- "type": "object",
95
- "properties": {
96
- "name": {
97
- "type": "string"
98
- },
99
- "email": {
100
- "type": "string"
101
- }
102
- },
103
- "required": [
104
- "name",
105
- "email"
106
- ]
107
- }
108
- }
109
- }
110
- },
111
- "responses": {
112
- "200": {
113
- "description": "Success",
114
- "content": {
115
- "application/json": {
116
- "schema": {
117
- "type": "object",
118
- "properties": {
119
- "id": {
120
- "type": "string"
121
- },
122
- "name": {
123
- "type": "string"
124
- },
125
- "email": {
126
- "type": "string"
127
- },
128
- "isActive": {
129
- "type": "boolean"
130
- },
131
- "createdAt": {
132
- "type": "string"
133
- }
134
- },
135
- "required": [
136
- "id",
137
- "name",
138
- "email",
139
- "isActive",
140
- "createdAt"
141
- ]
142
- }
143
- }
144
- }
145
- }
146
- }
147
- }
148
- },
149
- "/users/{userId}": {
150
- "get": {
151
- "operationId": "getUser",
152
- "parameters": [
153
- {
154
- "name": "userId",
155
- "in": "path",
156
- "required": true,
157
- "schema": {
158
- "type": "string"
159
- }
160
- },
161
- {
162
- "name": "details",
163
- "in": "query",
164
- "required": false,
165
- "schema": {
166
- "type": "integer",
167
- "enum": [
168
- null,
169
- null
170
- ]
171
- }
172
- }
173
- ],
174
- "responses": {
175
- "200": {
176
- "description": "Success",
177
- "content": {
178
- "application/json": {
179
- "schema": {
180
- "type": "string"
181
- }
182
- }
183
- }
184
- }
185
- }
186
- }
187
- },
188
- "/users/": {
189
- "post": {
190
- "operationId": "createUser",
191
- "parameters": [],
192
- "requestBody": {
193
- "content": {
194
- "application/json": {
195
- "schema": {
196
- "type": "object",
197
- "properties": {
198
- "name": {
199
- "type": "string"
200
- },
201
- "email": {
202
- "type": "string"
203
- }
204
- },
205
- "required": [
206
- "name",
207
- "email"
208
- ]
209
- }
210
- }
211
- }
212
- },
213
- "responses": {
214
- "200": {
215
- "description": "Success",
216
- "content": {
217
- "application/json": {
218
- "schema": {
219
- "type": "string"
220
- }
221
- }
222
- }
223
- }
224
- }
225
- }
226
- }
227
- },
228
- "components": {
229
- "schemas": {},
230
- "securitySchemes": {
231
- "bearerAuth": {
232
- "type": "http",
233
- "scheme": "bearer",
234
- "bearerFormat": "JWT"
235
- }
236
- }
237
- }
238
- }
package/tests/e2e.test.ts DELETED
@@ -1,72 +0,0 @@
1
- import { afterAll, beforeAll, describe, expect, it } from "vitest";
2
- import { spawn, ChildProcessWithoutNullStreams } from "node:child_process";
3
- import path from "node:path";
4
- import { projectRoot, runTsNodeScript } from "./utils.js";
5
-
6
- const BASE_URL = "http://localhost:3000";
7
-
8
- let serverProcess: ChildProcessWithoutNullStreams | undefined;
9
-
10
- beforeAll(
11
- async () => {
12
- await runTsNodeScript("src/cli/generate-swagger.ts");
13
- await runTsNodeScript("src/cli/generate-routes.ts");
14
- serverProcess = spawn(process.execPath, [path.join(projectRoot, "scripts", "run-example.js")], {
15
- cwd: projectRoot,
16
- stdio: ["ignore", "pipe", "pipe"],
17
- });
18
-
19
- await waitForServerReady(serverProcess);
20
- },
21
- 30000
22
- );
23
-
24
- afterAll(() => {
25
- if (serverProcess && !serverProcess.killed) {
26
- serverProcess.kill();
27
- }
28
- });
29
-
30
- describe("adorn-api example server", () => {
31
- it("lists users from the advanced endpoint", async () => {
32
- const response = await fetch(`${BASE_URL}/advanced/tenant-12/users?page=1&limit=5`);
33
- expect(response.status).toBe(200);
34
- const body = await response.json();
35
- expect(Array.isArray(body)).toBe(true);
36
- expect(body[0]).toMatchObject({
37
- id: "1",
38
- name: "Alice",
39
- });
40
- });
41
-
42
- it("returns user details from the user controller", async () => {
43
- const response = await fetch(`${BASE_URL}/users/abc?details=true`);
44
- expect(response.status).toBe(200);
45
- const text = await response.text();
46
- expect(text).toContain("Getting user abc");
47
- expect(text).toContain("details: true");
48
- });
49
- });
50
-
51
- async function waitForServerReady(proc: ChildProcessWithoutNullStreams, timeoutMs = 20000) {
52
- const deadline = Date.now() + timeoutMs;
53
- while (Date.now() < deadline) {
54
- if (proc.exitCode !== null) {
55
- throw new Error("Example server exited before becoming ready");
56
- }
57
-
58
- try {
59
- const response = await fetch(`${BASE_URL}/docs`);
60
- if (response.ok) {
61
- await response.text();
62
- return;
63
- }
64
- } catch {
65
- // ignore errors while the server is starting
66
- }
67
-
68
- await new Promise((resolve) => setTimeout(resolve, 250));
69
- }
70
-
71
- throw new Error("Timed out waiting for the example server to become ready");
72
- }
@@ -1,52 +0,0 @@
1
- // src/controllers/advanced.controller.ts
2
- import { Controller, Get, Post, FromBody, FromPath, PaginationQuery, EntityResponse, CreateInput } from "../../../src/index.js";
3
- import { User } from "../entities/user.entity.js";
4
-
5
- // --- 1. Advanced Request DTOs ---
6
-
7
- // INHERITANCE: UserListRequest automatically gets 'page' and 'limit' from PaginationQuery
8
- // AND the generator will find them because we scan the Type properties.
9
- export class UserListRequest extends PaginationQuery {
10
- // Implicitly @FromQuery because it's a GET request and extends a class
11
- search?: string;
12
-
13
- @FromPath()
14
- tenantId!: string;
15
- }
16
-
17
- // COMPOSITION: Using the Type Helper for safety, but class for Decorators
18
- // We implement the Type Helper to ensure our Class matches the Entity rule
19
- export class CreateUserDto implements CreateInput<User, 'name' | 'email'> {
20
- @FromBody()
21
- name!: string;
22
-
23
- @FromBody()
24
- email!: string;
25
-
26
- // If I miss a field here that is required in CreateInput, TS throws an error at edit time.
27
- }
28
-
29
- // --- 2. The Controller ---
30
-
31
- @Controller("advanced")
32
- export class AdvancedController {
33
-
34
- @Get("/{tenantId}/users")
35
- // Generic Return Type: The generator must resolve EntityResponse<User[]> -> User schema
36
- public async listUsers(req: UserListRequest): Promise<EntityResponse<User[]>> {
37
- return [
38
- { id: "1", name: "Alice", email: "a@a.com", isActive: true, createdAt: "now" }
39
- ];
40
- }
41
-
42
- @Post("/")
43
- public async create(req: CreateUserDto): Promise<EntityResponse<User>> {
44
- return {
45
- id: "123",
46
- name: req.name,
47
- email: req.email,
48
- isActive: true,
49
- createdAt: "now"
50
- };
51
- }
52
- }
@@ -1,35 +0,0 @@
1
- // src/controllers/user.controller.ts
2
- import { Controller, Get, Post, FromQuery, FromPath, FromBody } from "../../../src/index.js";
3
-
4
- // --- DTO Definitions (The substitute for Parameter Decorators) ---
5
- export class GetUserRequest {
6
- @FromPath()
7
- userId!: string;
8
-
9
- @FromQuery()
10
- details?: boolean;
11
- }
12
-
13
- export class CreateUserRequest {
14
- @FromBody()
15
- name!: string;
16
-
17
- @FromBody()
18
- email!: string;
19
- }
20
-
21
- // --- The Controller ---
22
- @Controller("users")
23
- export class UserController {
24
-
25
- // Strong typing: 'req' is checked at edit time.
26
- @Get("/{userId}")
27
- public async getUser(req: GetUserRequest): Promise<string> {
28
- return `Getting user ${req.userId} with details: ${req.details}`;
29
- }
30
-
31
- @Post("/")
32
- public async createUser(req: CreateUserRequest): Promise<void> {
33
- console.log(`Creating user ${req.name}`);
34
- }
35
- }
@@ -1,8 +0,0 @@
1
- // src/entities/user.entity.ts
2
- export interface User {
3
- id: string;
4
- name: string;
5
- email: string;
6
- isActive: boolean;
7
- createdAt: string;
8
- }
@@ -1,16 +0,0 @@
1
- // src/middleware/auth.middleware.ts
2
- import { Request, Response, NextFunction } from "express";
3
-
4
- export function authenticationMiddleware(req: Request, res: Response, next: NextFunction) {
5
- const token = req.headers.authorization;
6
- if (!token) {
7
- res.status(401).json({ message: "No token provided" });
8
- return;
9
- }
10
-
11
- if (token === "Bearer secret") {
12
- next();
13
- } else {
14
- res.status(403).json({ message: "Invalid token" });
15
- }
16
- }
@@ -1,102 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- // WARNING: This file was auto-generated by adorn-api. Do not edit.
4
- import { Express, Request, Response } from 'express';
5
- import { UserListRequest } from './controllers/advanced.controller.js';
6
- import { CreateUserDto } from './controllers/advanced.controller.js';
7
- import { AdvancedController } from './controllers/advanced.controller.js';
8
- import { GetUserRequest } from './controllers/user.controller.js';
9
- import { CreateUserRequest } from './controllers/user.controller.js';
10
- import { UserController } from './controllers/user.controller.js';
11
-
12
- export function RegisterRoutes(app: Express) {
13
-
14
- app.get('/advanced/:tenantId/users', async (req: Request, res: Response) => {
15
- const controller = new AdvancedController();
16
- try {
17
-
18
- const input: any = {};
19
- // Map Query
20
- Object.assign(input, req.query);
21
- // Map Params
22
- Object.assign(input, req.params);
23
- // Map Body
24
- Object.assign(input, req.body);
25
-
26
- // In a real app, you would run 'zod' or 'class-validator' here on 'input'
27
-
28
- const response = await controller.listUsers(input);
29
- res.status(200).json(response);
30
- } catch (err: any) {
31
- console.error(err);
32
- res.status(500).send(err.message);
33
- }
34
- });
35
-
36
- app.post('/advanced/', async (req: Request, res: Response) => {
37
- const controller = new AdvancedController();
38
- try {
39
-
40
- const input: any = {};
41
- // Map Query
42
- Object.assign(input, req.query);
43
- // Map Params
44
- Object.assign(input, req.params);
45
- // Map Body
46
- Object.assign(input, req.body);
47
-
48
- // In a real app, you would run 'zod' or 'class-validator' here on 'input'
49
-
50
- const response = await controller.create(input);
51
- res.status(200).json(response);
52
- } catch (err: any) {
53
- console.error(err);
54
- res.status(500).send(err.message);
55
- }
56
- });
57
-
58
- app.get('/users/:userId', async (req: Request, res: Response) => {
59
- const controller = new UserController();
60
- try {
61
-
62
- const input: any = {};
63
- // Map Query
64
- Object.assign(input, req.query);
65
- // Map Params
66
- Object.assign(input, req.params);
67
- // Map Body
68
- Object.assign(input, req.body);
69
-
70
- // In a real app, you would run 'zod' or 'class-validator' here on 'input'
71
-
72
- const response = await controller.getUser(input);
73
- res.status(200).json(response);
74
- } catch (err: any) {
75
- console.error(err);
76
- res.status(500).send(err.message);
77
- }
78
- });
79
-
80
- app.post('/users/', async (req: Request, res: Response) => {
81
- const controller = new UserController();
82
- try {
83
-
84
- const input: any = {};
85
- // Map Query
86
- Object.assign(input, req.query);
87
- // Map Params
88
- Object.assign(input, req.params);
89
- // Map Body
90
- Object.assign(input, req.body);
91
-
92
- // In a real app, you would run 'zod' or 'class-validator' here on 'input'
93
-
94
- const response = await controller.createUser(input);
95
- res.status(200).json(response);
96
- } catch (err: any) {
97
- console.error(err);
98
- res.status(500).send(err.message);
99
- }
100
- });
101
-
102
- }
@@ -1,30 +0,0 @@
1
- // tests/example-app/server.ts
2
- // Example Express server using adorn-api
3
- import express, { Express } from "express";
4
- import bodyParser from "body-parser";
5
- import { readFileSync } from "fs";
6
- import { fileURLToPath } from "url";
7
- import { dirname, join } from "path";
8
- import swaggerUi from "swagger-ui-express";
9
-
10
- // Import generated routes
11
- import { RegisterRoutes } from "./routes.js";
12
-
13
- const __filename = fileURLToPath(import.meta.url);
14
- const __dirname = dirname(__filename);
15
-
16
- const app: Express = express();
17
-
18
- app.use(bodyParser.json());
19
-
20
- // Register the Generated Routes
21
- RegisterRoutes(app);
22
-
23
- // Serve Swagger UI
24
- const swaggerDoc = JSON.parse(readFileSync(join(__dirname, "../../swagger.json"), "utf-8"));
25
- app.use("/docs", swaggerUi.serve, swaggerUi.setup(swaggerDoc));
26
-
27
- app.listen(3000, () => {
28
- console.log("🚀 Example server running on http://localhost:3000");
29
- console.log("📄 Swagger running on http://localhost:3000/docs");
30
- });