arkos 1.3.1-beta → 1.3.2-beta

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 (256) hide show
  1. package/dist/cjs/app.js +139 -1
  2. package/dist/cjs/exports/auth/index.js +6 -1
  3. package/dist/cjs/exports/controllers/index.js +11 -1
  4. package/dist/cjs/exports/error-handler/index.js +11 -1
  5. package/dist/cjs/exports/index.js +12 -1
  6. package/dist/cjs/exports/middlewares/index.js +7 -1
  7. package/dist/cjs/exports/prisma/index.js +13 -1
  8. package/dist/cjs/exports/services/index.js +48 -1
  9. package/dist/cjs/exports/utils/index.js +44 -1
  10. package/dist/cjs/exports/validation/index.js +11 -1
  11. package/dist/cjs/modules/auth/auth.controller.js +229 -1
  12. package/dist/cjs/modules/auth/auth.controller.js.map +1 -1
  13. package/dist/cjs/modules/auth/auth.router.js +82 -1
  14. package/dist/cjs/modules/auth/auth.router.js.map +1 -1
  15. package/dist/cjs/modules/auth/auth.service.js +226 -1
  16. package/dist/cjs/modules/auth/utils/auth-error-objects.js +10 -1
  17. package/dist/cjs/modules/auth/utils/helpers/auth.controller.helpers.js +83 -1
  18. package/dist/cjs/modules/auth/utils/services/auth-action.service.js +92 -1
  19. package/dist/cjs/modules/auth/utils/services/auth-action.service.js.map +1 -1
  20. package/dist/cjs/modules/base/base.controller.js +172 -1
  21. package/dist/cjs/modules/base/base.middlewares.js +92 -1
  22. package/dist/cjs/modules/base/base.router.js +22 -1
  23. package/dist/cjs/modules/base/base.service.js +507 -1
  24. package/dist/cjs/modules/base/base.service.js.map +1 -1
  25. package/dist/cjs/modules/base/types/base.service.types.js +3 -1
  26. package/dist/cjs/modules/base/types/base.service.types.js.map +1 -1
  27. package/dist/cjs/modules/base/utils/helpers/base.controller.helpers.js +80 -1
  28. package/dist/cjs/modules/base/utils/helpers/base.middlewares.helpers.js +50 -1
  29. package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +104 -1
  30. package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js +208 -1
  31. package/dist/cjs/modules/base/utils/router-validator.js +16 -1
  32. package/dist/cjs/modules/base/utils/service-hooks-manager.js +19 -1
  33. package/dist/cjs/modules/email/email.service.js +104 -1
  34. package/dist/cjs/modules/error-handler/error-handler.controller.js +146 -4
  35. package/dist/cjs/modules/error-handler/utils/app-error.js +17 -1
  36. package/dist/cjs/modules/error-handler/utils/catch-async.js +21 -1
  37. package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js +205 -3
  38. package/dist/cjs/modules/file-upload/file-upload.controller.js +233 -1
  39. package/dist/cjs/modules/file-upload/file-upload.router.js +60 -1
  40. package/dist/cjs/modules/file-upload/file-upload.service.js +322 -1
  41. package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js +97 -1
  42. package/dist/cjs/modules/swagger/swagger.router.js +38 -1
  43. package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +338 -1
  44. package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js +64 -1
  45. package/dist/cjs/modules/swagger/utils/helpers/get-system-json-schema-paths.js +37 -1
  46. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +48 -1
  47. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +32 -1
  48. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-system-json-schemas.js +49 -1
  49. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js +34 -1
  50. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +471 -1
  51. package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js +572 -1
  52. package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js +260 -1
  53. package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +112 -1
  54. package/dist/cjs/paths.js +9 -1
  55. package/dist/cjs/server.js +94 -5
  56. package/dist/cjs/types/arkos-config.js +3 -1
  57. package/dist/cjs/types/arkos-config.js.map +1 -1
  58. package/dist/cjs/types/auth.js +3 -1
  59. package/dist/cjs/types/index.js +11 -1
  60. package/dist/cjs/types/router-config.js +3 -1
  61. package/dist/cjs/utils/arkos-env.js +9 -1
  62. package/dist/cjs/utils/cli/build.js +214 -5
  63. package/dist/cjs/utils/cli/dev.js +154 -3
  64. package/dist/cjs/utils/cli/generate.js +109 -1
  65. package/dist/cjs/utils/cli/index.js +104 -1
  66. package/dist/cjs/utils/cli/index.js.map +1 -1
  67. package/dist/cjs/utils/cli/prisma-generate.js +120 -0
  68. package/dist/cjs/utils/cli/prisma-generate.js.map +1 -0
  69. package/dist/cjs/utils/cli/start.js +103 -1
  70. package/dist/cjs/utils/cli/utils/cli.helpers.js +24 -1
  71. package/dist/cjs/utils/cli/utils/smart-fs-watcher.js +73 -1
  72. package/dist/cjs/utils/cli/utils/template-generator/templates/auth-configs-template.js +36 -0
  73. package/dist/cjs/utils/cli/utils/template-generator/templates/auth-configs-template.js.map +1 -0
  74. package/dist/cjs/utils/cli/utils/template-generator/templates/controller-template.js +21 -0
  75. package/dist/cjs/utils/cli/utils/template-generator/templates/controller-template.js.map +1 -0
  76. package/dist/cjs/utils/cli/utils/template-generator/templates/hooks-template.js +201 -0
  77. package/dist/cjs/utils/cli/utils/template-generator/templates/hooks-template.js.map +1 -0
  78. package/dist/cjs/utils/cli/utils/template-generator/templates/middlewares-template.js +288 -0
  79. package/dist/cjs/utils/cli/utils/template-generator/templates/{generate-middlewares.js.map → middlewares-template.js.map} +1 -1
  80. package/dist/cjs/utils/cli/utils/template-generator/templates/query-options-template.js +64 -0
  81. package/dist/cjs/utils/cli/utils/template-generator/templates/query-options-template.js.map +1 -0
  82. package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js +45 -0
  83. package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js.map +1 -0
  84. package/dist/cjs/utils/cli/utils/template-generator/templates/service-template.js +29 -0
  85. package/dist/cjs/utils/cli/utils/template-generator/templates/service-template.js.map +1 -0
  86. package/dist/cjs/utils/cli/utils/template-generators.js +34 -2
  87. package/dist/cjs/utils/cli/utils/template-generators.js.map +1 -1
  88. package/dist/cjs/utils/cli/utils/watermark-stamper.js +17 -3
  89. package/dist/cjs/utils/dotenv.helpers.js +43 -1
  90. package/dist/cjs/utils/dynamic-loader.js +270 -9
  91. package/dist/cjs/utils/features/api.features.js +169 -1
  92. package/dist/cjs/utils/features/change-case.features.js +67 -1
  93. package/dist/cjs/utils/features/port-and-host-allocator.js +105 -1
  94. package/dist/cjs/utils/helpers/api.features.helpers.js +112 -1
  95. package/dist/cjs/utils/helpers/change-case.helpers.js +177 -1
  96. package/dist/cjs/utils/helpers/deepmerge.helper.js +115 -1
  97. package/dist/cjs/utils/helpers/dynamic-loader.helpers.js +76 -1
  98. package/dist/cjs/utils/helpers/fs.helpers.js +57 -1
  99. package/dist/cjs/utils/helpers/global.helpers.js +94 -1
  100. package/dist/cjs/utils/helpers/prisma.helpers.js +40 -1
  101. package/dist/cjs/utils/helpers/query-parser.helpers.js +45 -1
  102. package/dist/cjs/utils/helpers/routers.helpers.js +37 -1
  103. package/dist/cjs/utils/helpers/text.helpers.js +28 -1
  104. package/dist/cjs/utils/prisma/prisma-json-schema-generator.js +455 -1
  105. package/dist/cjs/utils/prisma/prisma-schema-parser.js +216 -4
  106. package/dist/cjs/utils/prisma/types.js +3 -1
  107. package/dist/cjs/utils/sheu.js +120 -1
  108. package/dist/cjs/utils/validate-dto.js +17 -1
  109. package/dist/cjs/utils/validate-schema.js +15 -1
  110. package/dist/esm/app.js +132 -1
  111. package/dist/esm/exports/auth/index.js +2 -1
  112. package/dist/esm/exports/controllers/index.js +4 -1
  113. package/dist/esm/exports/error-handler/index.js +4 -1
  114. package/dist/esm/exports/index.js +8 -1
  115. package/dist/esm/exports/middlewares/index.js +2 -1
  116. package/dist/esm/exports/prisma/index.js +6 -1
  117. package/dist/esm/exports/services/index.js +9 -1
  118. package/dist/esm/exports/utils/index.js +4 -1
  119. package/dist/esm/exports/validation/index.js +4 -1
  120. package/dist/esm/modules/auth/auth.controller.js +222 -1
  121. package/dist/esm/modules/auth/auth.controller.js.map +1 -1
  122. package/dist/esm/modules/auth/auth.router.js +76 -1
  123. package/dist/esm/modules/auth/auth.router.js.map +1 -1
  124. package/dist/esm/modules/auth/auth.service.js +219 -1
  125. package/dist/esm/modules/auth/utils/auth-error-objects.js +4 -1
  126. package/dist/esm/modules/auth/utils/helpers/auth.controller.helpers.js +73 -1
  127. package/dist/esm/modules/auth/utils/services/auth-action.service.js +90 -1
  128. package/dist/esm/modules/auth/utils/services/auth-action.service.js.map +1 -1
  129. package/dist/esm/modules/base/base.controller.js +165 -1
  130. package/dist/esm/modules/base/base.middlewares.js +81 -1
  131. package/dist/esm/modules/base/base.router.js +15 -1
  132. package/dist/esm/modules/base/base.service.js +500 -1
  133. package/dist/esm/modules/base/base.service.js.map +1 -1
  134. package/dist/esm/modules/base/types/base.service.types.js +2 -1
  135. package/dist/esm/modules/base/types/base.service.types.js.map +1 -1
  136. package/dist/esm/modules/base/utils/helpers/base.controller.helpers.js +76 -1
  137. package/dist/esm/modules/base/utils/helpers/base.middlewares.helpers.js +44 -1
  138. package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +96 -1
  139. package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +198 -1
  140. package/dist/esm/modules/base/utils/router-validator.js +14 -1
  141. package/dist/esm/modules/base/utils/service-hooks-manager.js +17 -1
  142. package/dist/esm/modules/email/email.service.js +97 -1
  143. package/dist/esm/modules/error-handler/error-handler.controller.js +107 -4
  144. package/dist/esm/modules/error-handler/utils/app-error.js +15 -1
  145. package/dist/esm/modules/error-handler/utils/catch-async.js +19 -1
  146. package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +163 -3
  147. package/dist/esm/modules/file-upload/file-upload.controller.js +228 -1
  148. package/dist/esm/modules/file-upload/file-upload.router.js +54 -1
  149. package/dist/esm/modules/file-upload/file-upload.service.js +314 -1
  150. package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js +87 -1
  151. package/dist/esm/modules/swagger/swagger.router.js +32 -1
  152. package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +333 -1
  153. package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js +58 -1
  154. package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js +34 -1
  155. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +42 -1
  156. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +26 -1
  157. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-system-json-schemas.js +46 -1
  158. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js +28 -1
  159. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +465 -1
  160. package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js +566 -1
  161. package/dist/esm/modules/swagger/utils/helpers/missing-json-schemas-generator.js +255 -1
  162. package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +101 -1
  163. package/dist/esm/paths.js +3 -1
  164. package/dist/esm/server.js +85 -5
  165. package/dist/esm/types/arkos-config.js +2 -1
  166. package/dist/esm/types/arkos-config.js.map +1 -1
  167. package/dist/esm/types/auth.js +2 -1
  168. package/dist/esm/types/index.js +8 -1
  169. package/dist/esm/types/router-config.js +2 -1
  170. package/dist/esm/utils/arkos-env.js +7 -1
  171. package/dist/esm/utils/cli/build.js +208 -5
  172. package/dist/esm/utils/cli/dev.js +147 -3
  173. package/dist/esm/utils/cli/generate.js +103 -1
  174. package/dist/esm/utils/cli/index.js +94 -1
  175. package/dist/esm/utils/cli/index.js.map +1 -1
  176. package/dist/esm/utils/cli/prisma-generate.js +114 -0
  177. package/dist/esm/utils/cli/prisma-generate.js.map +1 -0
  178. package/dist/esm/utils/cli/start.js +96 -1
  179. package/dist/esm/utils/cli/utils/cli.helpers.js +16 -1
  180. package/dist/esm/utils/cli/utils/smart-fs-watcher.js +68 -1
  181. package/dist/esm/utils/cli/utils/template-generator/templates/auth-configs-template.js +33 -0
  182. package/dist/esm/utils/cli/utils/template-generator/templates/auth-configs-template.js.map +1 -0
  183. package/dist/esm/utils/cli/utils/template-generator/templates/controller-template.js +18 -0
  184. package/dist/esm/utils/cli/utils/template-generator/templates/controller-template.js.map +1 -0
  185. package/dist/esm/utils/cli/utils/template-generator/templates/hooks-template.js +198 -0
  186. package/dist/esm/utils/cli/utils/template-generator/templates/hooks-template.js.map +1 -0
  187. package/dist/esm/utils/cli/utils/template-generator/templates/middlewares-template.js +285 -0
  188. package/dist/esm/utils/cli/utils/template-generator/templates/{generate-middlewares.js.map → middlewares-template.js.map} +1 -1
  189. package/dist/esm/utils/cli/utils/template-generator/templates/query-options-template.js +61 -0
  190. package/dist/esm/utils/cli/utils/template-generator/templates/query-options-template.js.map +1 -0
  191. package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js +39 -0
  192. package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js.map +1 -0
  193. package/dist/esm/utils/cli/utils/template-generator/templates/service-template.js +26 -0
  194. package/dist/esm/utils/cli/utils/template-generator/templates/service-template.js.map +1 -0
  195. package/dist/esm/utils/cli/utils/template-generators.js +28 -2
  196. package/dist/esm/utils/cli/utils/template-generators.js.map +1 -1
  197. package/dist/esm/utils/cli/utils/watermark-stamper.js +15 -3
  198. package/dist/esm/utils/dotenv.helpers.js +37 -1
  199. package/dist/esm/utils/dynamic-loader.js +254 -9
  200. package/dist/esm/utils/features/api.features.js +162 -1
  201. package/dist/esm/utils/features/change-case.features.js +31 -1
  202. package/dist/esm/utils/features/port-and-host-allocator.js +67 -1
  203. package/dist/esm/utils/helpers/api.features.helpers.js +106 -1
  204. package/dist/esm/utils/helpers/change-case.helpers.js +161 -1
  205. package/dist/esm/utils/helpers/deepmerge.helper.js +113 -1
  206. package/dist/esm/utils/helpers/dynamic-loader.helpers.js +69 -1
  207. package/dist/esm/utils/helpers/fs.helpers.js +48 -1
  208. package/dist/esm/utils/helpers/global.helpers.js +51 -1
  209. package/dist/esm/utils/helpers/prisma.helpers.js +32 -1
  210. package/dist/esm/utils/helpers/query-parser.helpers.js +40 -1
  211. package/dist/esm/utils/helpers/routers.helpers.js +29 -1
  212. package/dist/esm/utils/helpers/text.helpers.js +22 -1
  213. package/dist/esm/utils/prisma/prisma-json-schema-generator.js +448 -1
  214. package/dist/esm/utils/prisma/prisma-schema-parser.js +209 -4
  215. package/dist/esm/utils/prisma/types.js +2 -1
  216. package/dist/esm/utils/sheu.js +118 -1
  217. package/dist/esm/utils/validate-dto.js +11 -1
  218. package/dist/esm/utils/validate-schema.js +9 -1
  219. package/dist/types/modules/auth/utils/services/auth-action.service.d.ts +1 -1
  220. package/dist/types/modules/base/types/base.service.types.d.ts +12 -9
  221. package/dist/types/types/arkos-config.d.ts +3 -2
  222. package/dist/types/utils/cli/prisma-generate.d.ts +1 -0
  223. package/package.json +2 -2
  224. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +0 -21
  225. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js.map +0 -1
  226. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-controller-template.js +0 -12
  227. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +0 -1
  228. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-hooks-template.js +0 -144
  229. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-hooks-template.js.map +0 -1
  230. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-middlewares.js +0 -256
  231. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +0 -36
  232. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +0 -1
  233. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-router-template.js +0 -18
  234. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-router-template.js.map +0 -1
  235. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js +0 -9
  236. package/dist/cjs/utils/cli/utils/template-generator/templates/generate-service-template.js.map +0 -1
  237. package/dist/esm/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js +0 -21
  238. package/dist/esm/utils/cli/utils/template-generator/templates/generate-auth-configs-template.js.map +0 -1
  239. package/dist/esm/utils/cli/utils/template-generator/templates/generate-controller-template.js +0 -12
  240. package/dist/esm/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +0 -1
  241. package/dist/esm/utils/cli/utils/template-generator/templates/generate-hooks-template.js +0 -144
  242. package/dist/esm/utils/cli/utils/template-generator/templates/generate-hooks-template.js.map +0 -1
  243. package/dist/esm/utils/cli/utils/template-generator/templates/generate-middlewares.js +0 -256
  244. package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js +0 -36
  245. package/dist/esm/utils/cli/utils/template-generator/templates/generate-prisma-query-options.js.map +0 -1
  246. package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js +0 -18
  247. package/dist/esm/utils/cli/utils/template-generator/templates/generate-router-template.js.map +0 -1
  248. package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js +0 -9
  249. package/dist/esm/utils/cli/utils/template-generator/templates/generate-service-template.js.map +0 -1
  250. /package/dist/types/utils/cli/utils/template-generator/templates/{generate-auth-configs-template.d.ts → auth-configs-template.d.ts} +0 -0
  251. /package/dist/types/utils/cli/utils/template-generator/templates/{generate-controller-template.d.ts → controller-template.d.ts} +0 -0
  252. /package/dist/types/utils/cli/utils/template-generator/templates/{generate-hooks-template.d.ts → hooks-template.d.ts} +0 -0
  253. /package/dist/types/utils/cli/utils/template-generator/templates/{generate-middlewares.d.ts → middlewares-template.d.ts} +0 -0
  254. /package/dist/types/utils/cli/utils/template-generator/templates/{generate-prisma-query-options.d.ts → query-options-template.d.ts} +0 -0
  255. /package/dist/types/utils/cli/utils/template-generator/templates/{generate-router-template.d.ts → router-template.d.ts} +0 -0
  256. /package/dist/types/utils/cli/utils/template-generator/templates/{generate-service-template.d.ts → service-template.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"arkos-config.js","sourceRoot":"","sources":["../../../src/types/arkos-config.ts"],"names":[],"mappings":"","sourcesContent":["import http from \"http\";\nimport cors from \"cors\";\nimport express from \"express\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport cookieParser from \"cookie-parser\";\nimport compression from \"compression\";\nimport { Options as QueryParserOptions } from \"../utils/helpers/query-parser.helpers\";\nimport { ValidatorOptions } from \"class-validator\";\nimport { MsDuration } from \"../modules/auth/utils/helpers/auth.controller.helpers\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport type { ApiReferenceConfiguration } from \"@scalar/express-api-reference\" with { \"resolution-mode\": \"import\" };\n\n/**\n * Defines the initial configs of the api to be loaded at startup when arkos.init() is called.\n */\nexport type ArkosConfig = {\n /**\n * Allows to configure request configs\n */\n request?: {\n /**\n * Allows to configure request parameters\n */\n parameters?: {\n /**\n * Toggles allowing `VERY DANGEROUS` request paramateres under `req.query` for passing prisma query options.\n *\n * See more\n */\n allowDangerousPrismaQueryOptions?: boolean;\n };\n };\n /** Message you would like to send, as Json and 200 response when\n * ```curl\n * GET /api\n * ```\n *\n * ```json\n * { \"message\": \"Welcome to YourAppName\" }\n * ```\n *\n * default message is: Welcome to our Rest API generated by Arkos, find more about Arkos at www.arkosjs.com.\n *\n *\n * */\n welcomeMessage?: string;\n /**\n * Port where the application will run, can be set in 3 ways:\n *\n * 1. default is 8000\n * 2. PORT under environment variables (Lower precedence)\n * 3. this config option (Higher precedence)\n */\n port?: number | undefined;\n /**\n * Allows to listen on a different host than localhost only\n */\n host?: string;\n /**\n * Defines authentication related configurations, by default is undefined.\n *\n * See [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for details.\n */\n authentication?: {\n /**\n * Defines whether to use Static or Dynamic Role-Based Acess Control\n *\n * Visit [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for more details.\n */\n mode: \"static\" | \"dynamic\";\n /**\n * Defines auth login related configurations to customize the api.\n */\n login?: {\n /**\n * Defines the field that will be used as username by the built-in auth system, by default arkos will look for the field \"username\" in your model User, hence when making login for example you must send:\n *\n * ```json\n * {\n * \"username\": \"johndoe\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n *\n * **Note:** You can also modify the usernameField on the fly by passing it to the request query parameters. example:\n *\n * ```curl\n * POST /api/auth/login?usernameField=email\n * ```\n *\n * See more at [www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds](https://www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds)\n *\n * By specifing here another field for username, for example passing \"email\", \"companyCode\" or something else your json will be like:\n *\n * **Example with email**\n *\n * ```json\n * {\n * \"email\": \"john.doe@example.com\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n */\n allowedUsernames?: string[];\n /** Defines wether to send the access token in response after login or only send as cookie, defeault is both.*/\n sendAccessTokenThrough?: \"cookie-only\" | \"response-only\" | \"both\";\n };\n /**\n * Specifies the regex pattern used by the authentication system to enforce password strength requirements.\n *\n * **Important**: If using validation libraries like Zod or class-validator, this will be completely overwritten.\n *\n * **Default**: ```/^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d).+$/``` - Ensures the password contains at least one uppercase letter, one lowercase letter, and one numeric digit.\n *\n * **message**: (Optional) A custom error message to display when the password does not meet the required strength criteria.\n */\n passwordValidation?: { regex: RegExp; message?: string };\n /**\n * Allows to specify the request rate limit for all authentication endpoints but `/api/users/me`.\n * \n * #### Default\n *{\n windowMs: 5000,\n limit: 10,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n *@see This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n requestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * JWT (JSON Web Token) authentication configuration.\n *\n * You can override these values directly in code, or use environment variables:\n *\n * - `JWT_SECRET`: Secret used to sign and verify JWT tokens.\n * - `JWT_EXPIRES_IN`: Duration string or number indicating when the token should expire (e.g. \"30d\", 3600).\n * - `JWT_COOKIE_SECURE`: Whether the cookie is sent only over HTTPS. Default: `true` in production.\n * - `JWT_COOKIE_HTTP_ONLY`: Whether the cookie is HTTP-only. Default: `true`.\n * - `JWT_COOKIE_SAME_SITE`: Can be \"lax\", \"strict\", or \"none\". Defaults to \"lax\" in dev, \"none\" in prod.\n *\n * ⚠️ Values passed here take precedence over environment variables.\n */\n jwt?: {\n /** Secret key used for signing and verifying JWT tokens */\n secret?: string;\n /**\n * Duration after which the JWT token expires.\n * Accepts either a duration string (e.g. \"30d\", \"1h\") or a number in milliseconds.\n * Defaults to \"30d\" if not provided.\n */\n expiresIn?: MsDuration | number;\n\n /**\n * Configuration for the JWT cookie sent to the client\n */\n cookie?: {\n /**\n * Whether the cookie should be marked as secure (sent only over HTTPS).\n * Defaults to `true` in production and `false` in development.\n */\n secure?: boolean;\n\n /**\n * Whether the cookie should be marked as HTTP-only.\n * Default is `true` to prevent access via JavaScript.\n */\n httpOnly?: boolean;\n\n /**\n * Controls the SameSite attribute of the cookie.\n * Defaults to \"none\" in production and \"lax\" in development.\n * Options: \"lax\" | \"strict\" | \"none\"\n */\n sameSite?: \"lax\" | \"strict\" | \"none\";\n };\n };\n };\n /** Allows to customize and toggle the built-in validation, by default it is set to `false`. If true is passed it will use validation with the default resolver set to `class-validator` if you intend to change the resolver to `zod` do the following:\n *\n *```ts\n * // src/app.ts\n * import arkos from 'arkos'\n *\n * arkos.init({\n * validation: {\n * resolver: \"zod\"\n * }\n * })\n * ```\n *\n * @See [www.arkosjs.com/docs/core-concepts/request-data-validation](https://www.arkosjs.com/docs/core-concepts/request-data-validation) for more details.\n */\n validation?:\n | {\n resolver?: \"class-validator\";\n /**\n * ValidatorOptions to used while validating request data.\n *\n * **Default**:\n * ```ts\n * {\n * whitelist: true\n * }\n * ```\n */\n validationOptions?: ValidatorOptions;\n }\n | {\n resolver?: \"zod\";\n validationOptions?: Record<string, any>;\n };\n /**\n * Defines file upload configurations\n *\n * See [www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations](https://www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations)\n */\n fileUpload?: {\n /**\n * Defiens the base file upload directory, default is set to /uploads (on root directory)\n *\n * When setting up a path dir always now that root directory will be the starting reference.\n *\n * #### Example\n * passing `../my-arkos-uploaded-files`\n *\n * Will save uploaded files one level outside the root dir inside `my-arkos-uploaded-files`\n *\n * NB: You must be aware of permissions on your server to acess files outside your project directory.\n *\n */\n baseUploadDir?: string;\n /**\n * Changes the default `/api/uploads` base route for accessing file upload route.\n *\n * #### IMPORTANT\n * Changing this will not affect the `baseUploadDir` folder. You can\n * pass here `/api/files/my-user-files` and `baseUploadDir` be `/uploaded-files`.\n *\n */\n baseRoute?: string;\n /**\n * Defines options for `express.static(somePath, someOptions)`\n *\n * #### Default:\n *\n * ```ts\n *{\n maxAge: \"1y\",\n etag: true,\n lastModified: true,\n dotfiles: \"ignore\",\n fallthrough: true,\n index: false,\n cacheControl: true,\n }\n * ```\n * \n * By passing your custom options have in mind that it\n * will be deepmerged with the default.\n * \n * Visit [https://expressjs.com/en/4x/api.html#express.static](https://expressjs.com/en/4x/api.html#express.static) for more understanding.\n * \n */\n expressStaticOptions?: Parameters<typeof express.static>[1];\n /**\n * Defines upload restrictions for each file type: image, video, document or other.\n *\n * #### Important:\n * Passing an object without overriding everything will only cause it\n * to be deepmerged with the default options.\n *\n * See [www.arkosjs.com/docs/api-reference/default-supported-upload-files](https://www.arkosjs.com/docs/api-reference/default-supported-upload-files) for detailed explanation about default values.\n * ```\n */\n restrictions?: {\n images?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n videos?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n documents?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n files?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n };\n };\n /**\n * Allows to specify the request rate limit for all endpoints.\n * \n * #### Default\n *```ts\n *{\n windowMs: 60 * 1000,\n limit: 1000,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n ```\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n * This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n globalRequestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * Defines options for the built-in express.json() middleware\n * Nothing is passed by default.\n */\n jsonBodyParserOptions?: Parameters<typeof express.json>[0];\n /**\n * Allows to pass paremeters to cookieParser from npm package cookie-parser\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/cookie-parser](https://www.npmjs.com/package/cookie-parser) for further details.\n */\n cookieParserParameters?: Parameters<typeof cookieParser>;\n /**\n * Allows to define options for npm package compression\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/compression](https://www.npmjs.com/package/compression) for further details.\n */\n compressionOptions?: compression.CompressionOptions;\n /**\n * Options to define how query must be parsed.\n *\n * #### for example:\n * ```\n * GET /api/product?saleId=null\n * ```\n *\n * Normally would parsed to { saleId: \"null\" } so query parser\n * trough setting option `parseNull` will transform { saleId: null }\n * \n * #### Default:\n * \n * {\n parseNull: true,\n parseUndefined: true,\n parseBoolean: true,\n }\n * \n * parseNumber may convert fields that are string but you only passed\n * numbers to query pay attention to this.\n * \n * Soon a feature to converted the query to the end prisma type will be added.\n */\n queryParserOptions?: QueryParserOptions;\n /**\n * Configuration for CORS (Cross-Origin Resource Sharing).\n *\n * @property {string | string[] | \"all\"} [allowedOrigins] - List of allowed origins. If set to `\"all\"`, all origins are accepted.\n * @property {import('cors').CorsOptions} [options] - Additional CORS options passed directly to the `cors` middleware.\n * @property {import('cors').CorsOptionsDelegate} [customMiddleware] - A custom middleware function that overrides the default behavior.\n *\n * @remarks\n * If `customMiddleware` is provided, both `allowedOrigins` and `options` will be ignored in favor of the custom logic.\n *\n * See https://www.npmjs.com/package/cors\n */\n cors?: {\n /**\n * Defines allowed origins to acess the API.\n */\n allowedOrigins?: string | string[] | \"*\";\n options?: cors.CorsOptions;\n /**\n * If you would like to override the entire middleware\n *\n * see\n */\n customHandler?: cors.CorsOptionsDelegate;\n };\n /**\n * Defines express/arkos middlewares configurations\n */\n middlewares?: {\n /**\n * Allows to add an array of custom express middlewares into the default middleware stack.\n *\n * **Tip**: If you would like to acess the express app before everthing use `configureApp` and pass a function.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order](https://www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order)\n *\n * **Note**: If you want to use custom global error handler middleware use `middlewares.replace.globalErrorHandler`.\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.RequestHandler[];\n /**\n * An array containing a list of defaults middlewares to be disabled\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n *\n */\n disable?: (\n | \"compression\"\n | \"global-rate-limit\"\n | \"auth-rate-limit\"\n | \"cors\"\n | \"express-json\"\n | \"cookie-parser\"\n | \"query-parser\"\n | \"request-logger\"\n | \"global-error-handler\"\n )[];\n /**\n * Allows you to replace each of the built-in middlewares with your own implementation\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default compression middleware\n */\n compression?: express.RequestHandler;\n /**\n * Replace the default global rate limit middleware\n */\n globalRateLimit?: express.RequestHandler;\n /**\n * Replace the default authentication rate limit middleware\n */\n authRateLimit?: express.RequestHandler;\n /**\n * Replace the default CORS middleware\n */\n cors?: express.RequestHandler;\n /**\n * Replace the default JSON body parser middleware\n */\n expressJson?: express.RequestHandler;\n /**\n * Replace the default cookie parser middleware\n */\n cookieParser?: express.RequestHandler;\n /**\n * Replace the default query parser middleware\n */\n queryParser?: express.RequestHandler;\n /**\n * Replace the default request logger middleware\n */\n requestLogger?: express.RequestHandler;\n /**\n * Replace the default global error handler middleware\n */\n globalErrorHandler?: express.ErrorRequestHandler;\n };\n };\n /**\n * Defines express/arkos routers configurations\n */\n routers?: {\n /**\n * Strict mode configuration for routing security\n *\n * @default false\n * - all CRUD + Auth (if using auth) endpoits are enabled and avialable by default.\n *\n * When enabled:\n * - If `true`: All CRUD endpoints start disabled and must be explicitly enabled\n * in each model's router configuration\n * - If `'no-bulk'`: Bulk operations (createMany, updateMany, deleteMany) are disabled\n * by default, while individual operations can be enabled per model\n *\n * This provides enhanced security by ensuring no routes are accidentally exposed.\n * Use this in production environments to follow the principle of least privilege.\n *\n * See documentation: https://www.arkosjs.com/docs/guide/security#strict-mode\n */\n strict?: boolean | \"no-bulk\";\n /**\n * Allows to add an array of custom express routers into the default middleware/router stack.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/adding-custom-routers](https://www.arkosjs.com/docs/advanced-guide/adding-custom-routers)\n *\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.Router[];\n disable?: (\n | \"auth-router\"\n | \"prisma-models-router\"\n | \"file-upload\"\n | \"welcome-endpoint\"\n )[];\n /**\n * Allows you to replace each of the built-in routers with your own implementation.\n *\n * **Note**: Doing this you will lose all default middleware chaining, auth control, handlers from the specific router.\n *\n * **Tip**: I you want to disable some prisma models specific endpoint\n * see [www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints](https://www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints)\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default authentication router\n * @param config The original Arkos configuration\n * @returns A router handling authentication endpoints\n */\n authRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default Prisma models router\n * @param config The original Arkos configuration\n * @returns A router handling Prisma model endpoints\n */\n prismaModelsRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default file upload router\n * @param config The original Arkos configuration\n * @returns A router handling file upload endpoints\n */\n fileUpload?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default welcome endpoint handler\n * @param req Express request object\n * @param res Express response object\n * @param next Express next function\n */\n welcomeEndpoint?: express.RequestHandler;\n };\n };\n /**\n * Gives acess to the underlying express app so that you can add custom configurations beyong **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `app.listen` for you.\n *\n * If you want to call `app.listen` by yourself pass port as `undefined` and then use the return app from `arkos.init()`.\n *\n * See how to call `app.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself](https://www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app](https://www.arkosjs.com/docs/guide/accessing-the-express-app) for further details on the method configureApp.\n *\n * @param {express.Express} app\n * @returns {any}\n */\n configureApp?: (app: express.Express) => Promise<any> | any;\n /**\n * Gives access to the underlying HTTP server so that you can add custom configurations beyond **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `server.listen` for you.\n *\n * If you want to call `server.listen` by yourself pass port as `undefined` and then use the return server from `arkos.init()`.\n *\n * See how to call `server.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server) for further details on the method configureServer.\n *\n * @param {http.Server} server - The HTTP server instance\n * @returns {any}\n */\n configureServer?: (server: http.Server) => Promise<any> | any;\n /**\n * Allows to configure email configurations for sending emails through `emailService`\n *\n * See [www.arkosjs.com/docs/core-concepts/sending-emails](https://www.arkosjs.com/docs/core-concepts/sending-emails)\n */\n email?: {\n /**\n * Your email provider url\n */\n host: string;\n /**\n * Email provider SMTP port, Default is `465`\n */\n port?: number;\n /**\n * If smtp connection must be secure, Default is `true`\n */\n secure?: boolean;\n /**\n * Used to authenticate in your smtp server\n */\n auth: {\n /**\n * Email used for auth as well as sending emails\n */\n user: string;\n /**\n * Your SMTP password\n */\n pass: string;\n };\n /**\n * Email name to used like:\n *\n * John Doe\\<john.doe@gmail.com>\n */\n name?: string;\n };\n /**\n * Defines Swagger and OpenApi specifications for auto generating swagger documentation UI using whether it is Prisma Schemas, Class-validator DTOs, Zod Schemas or JSON-Schemas.\n *\n * **Important**: Is worth mentioning that this works alongside `@scalar/express-api-reference` npm package, you define it's ApiReferenceConfiguration under ``. also consider checking the package documentation at []\n *\n * **Usage**\n *\n * ```ts\n * // src/app.ts\n *\n * import arkos from \"arkos\"\n *\n * arkos.init({\n * // other configs\n * swagger: {\n * mode: \"zod\",\n * options: {\n * defintion: {\n * info: {\n * openapi: \"3.0.0\",\n * title: \"API Generated By Arkos.js\",\n * description: \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n * }\n * }\n * }\n * }\n * })\n * ```\n * @see {@link https://www.arkosjs.com/docs/core-concepts/swagger-api-documentation}\n */\n swagger?: {\n /**\n * By default Arkos will disable API Documentation when the project is built `npm run build`, it does not matter what node environment is set. If you want to use it even after the `arkos build` command just set this to `true`.\n * */\n enableAfterBuild?: boolean;\n /**\n * Endpoint where the Swagger UI will be available.\n *\n * @default \"/api/api-docs\"\n */\n endpoint?: string;\n /**\n * Determines how your API schemas should be generated.\n *\n * - \"prisma\": Generates schemas based on Prisma models\n * - \"class-validator\": Uses class-validator and class-transformer DTO classes\n * - \"zod\": Uses OpenAPI-compliant schemas directly\n */\n mode: \"prisma\" | \"class-validator\" | \"zod\";\n /**\n * Allows `Arkos.js` to fallback to prisma schema and use them as json schema for defining request body and response data\n * when a given zod Schema or class-validator Class is not found to be transformed to json schema.\n *\n * @default false\n */\n strict?: boolean;\n /**\n * Defines your swagger configurations\n */\n options?: {\n /**\n * Swagger definition according to OpenAPI Specification.\n */\n definition?: {\n /**\n * OpenAPI version.\n *\n * @default \"3.0.0\"\n */\n openapi?: string;\n\n /**\n * Information about your API.\n */\n info?: {\n /**\n * Title of the API documentation.\n *\n *\n * @example \"My API\"\n *\n * @default \"API Generated By Arkos.js\"\n */\n title?: string;\n\n /**\n * Version of the API.\n *\n * @example \"1.0.0\"\n */\n version?: string;\n\n /**\n * Description of the API.\n *\n * @default \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n */\n description?: string;\n };\n\n /**\n * Server configurations for the API.\n *\n * @default [{ url: \"http://localhost:8000\", description: \"Development server\" }]\n *\n * This can be overridden automatically by Arkos based on CLI, .env, or `arkos.init()`.\n */\n servers?: {\n /**\n * Base URL of the server.\n *\n * @example \"http://localhost:8000\"\n */\n url: string;\n\n /**\n * Human-readable description of the server.\n *\n * @example \"Development Server\"\n */\n description?: string;\n }[];\n /**\n * Allows adding more paths for your OpenAPI documentation\n *\n * */\n paths?: OpenAPIV3.PathsObject;\n /**\n * (Optional) Additional metadata such as terms of service, contact, or license.\n *\n * See: https://swagger.io/specification/#infoObject\n */\n termsOfService?: string;\n contact?: {\n name?: string;\n url?: string;\n email?: string;\n };\n license?: {\n name: string;\n url?: string;\n };\n\n /**\n * Tags to group and describe endpoints.\n */\n tags?: {\n name: string;\n description?: string;\n }[];\n\n /**\n * Security definitions (e.g., Bearer Auth).\n */\n components?: {\n securitySchemes?: Record<string, any>;\n schemas?: Record<string, any>;\n };\n\n /**\n * Global security requirements.\n */\n security?: Array<Record<string, string[]>>;\n };\n\n /**\n * Glob patterns defining where Swagger should look for API route definitions and comments.\n *\n * @default \n * ```ts\n * [\"./src/routers/*.router.{ts,js}\", \"./src/modules/**\\/*.router.{ts,js}\"]\n ```\n *\n * Adjust depending on TypeScript or JavaScript usage.\n */\n apis?: string[];\n\n /**\n * Enables deep linking in the Swagger UI.\n *\n * @default true\n */\n deepLinking?: boolean;\n\n /**\n * Enable/disable the \"Try it out\" button globally.\n *\n * @default true\n */\n tryItOutEnabled?: boolean;\n\n /**\n * Whether to persist authorization data across page reloads.\n *\n * @default false\n */\n persistAuthorization?: boolean;\n };\n /**\n * Custom `@scalar/express-api-reference` package options.\n *\n * @see {@link https://guides.scalar.com/scalar/scalar-api-references/integrations/express}\n */\n scalarApiReferenceConfiguration?: Partial<ApiReferenceConfiguration>;\n };\n};\n"]}
1
+ {"version":3,"file":"arkos-config.js","sourceRoot":"","sources":["../../../src/types/arkos-config.ts"],"names":[],"mappings":"","sourcesContent":["import http from \"http\";\nimport cors from \"cors\";\nimport express from \"express\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport cookieParser from \"cookie-parser\";\nimport compression from \"compression\";\nimport { Options as QueryParserOptions } from \"../utils/helpers/query-parser.helpers\";\nimport { ValidatorOptions } from \"class-validator\";\nimport { MsDuration } from \"../modules/auth/utils/helpers/auth.controller.helpers\";\nimport { OpenAPIV3 } from \"openapi-types\";\nimport type { ApiReferenceConfiguration } from \"@scalar/express-api-reference\" with { \"resolution-mode\": \"import\" };\nimport nodemailer from \"nodemailer\";\n/**\n * Defines the initial configs of the api to be loaded at startup when arkos.init() is called.\n */\nexport type ArkosConfig = {\n /**\n * Allows to configure request configs\n */\n request?: {\n /**\n * Allows to configure request parameters\n */\n parameters?: {\n /**\n * Toggles allowing `VERY DANGEROUS` request paramateres under `req.query` for passing prisma query options.\n *\n * See more\n */\n allowDangerousPrismaQueryOptions?: boolean;\n };\n };\n /** Message you would like to send, as Json and 200 response when\n * ```curl\n * GET /api\n * ```\n *\n * ```json\n * { \"message\": \"Welcome to YourAppName\" }\n * ```\n *\n * default message is: Welcome to our Rest API generated by Arkos, find more about Arkos at www.arkosjs.com.\n *\n *\n * */\n welcomeMessage?: string;\n /**\n * Port where the application will run, can be set in 3 ways:\n *\n * 1. default is 8000\n * 2. PORT under environment variables (Lower precedence)\n * 3. this config option (Higher precedence)\n */\n port?: number | undefined;\n /**\n * Allows to listen on a different host than localhost only\n */\n host?: string;\n /**\n * Defines authentication related configurations, by default is undefined.\n *\n * See [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for details.\n */\n authentication?: {\n /**\n * Defines whether to use Static or Dynamic Role-Based Acess Control\n *\n * Visit [www.arkosjs.com/docs/core-concepts/authentication-system](https://www.arkosjs.com/docs/core-concepts/authentication-system) for more details.\n */\n mode: \"static\" | \"dynamic\";\n /**\n * Defines auth login related configurations to customize the api.\n */\n login?: {\n /**\n * Defines the field that will be used as username by the built-in auth system, by default arkos will look for the field \"username\" in your model User, hence when making login for example you must send:\n *\n * ```json\n * {\n * \"username\": \"johndoe\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n *\n * **Note:** You can also modify the usernameField on the fly by passing it to the request query parameters. example:\n *\n * ```curl\n * POST /api/auth/login?usernameField=email\n * ```\n *\n * See more at [www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds](https://www.arkosjs.com/docs/core-concepts/authentication-system#login-with-different-fileds)\n *\n * By specifing here another field for username, for example passing \"email\", \"companyCode\" or something else your json will be like:\n *\n * **Example with email**\n *\n * ```json\n * {\n * \"email\": \"john.doe@example.com\",\n * \"password\": \"somePassword123\"\n * }\n * ```\n */\n allowedUsernames?: string[];\n /** Defines wether to send the access token in response after login or only send as cookie, defeault is both.*/\n sendAccessTokenThrough?: \"cookie-only\" | \"response-only\" | \"both\";\n };\n /**\n * Specifies the regex pattern used by the authentication system to enforce password strength requirements.\n *\n * **Important**: If using validation libraries like Zod or class-validator, this will be completely overwritten.\n *\n * **Default**: ```/^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d).+$/``` - Ensures the password contains at least one uppercase letter, one lowercase letter, and one numeric digit.\n *\n * **message**: (Optional) A custom error message to display when the password does not meet the required strength criteria.\n */\n passwordValidation?: { regex: RegExp; message?: string };\n /**\n * Allows to specify the request rate limit for all authentication endpoints but `/api/users/me`.\n * \n * #### Default\n *{\n windowMs: 5000,\n limit: 10,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n *@see This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n requestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * JWT (JSON Web Token) authentication configuration.\n *\n * You can override these values directly in code, or use environment variables:\n *\n * - `JWT_SECRET`: Secret used to sign and verify JWT tokens.\n * - `JWT_EXPIRES_IN`: Duration string or number indicating when the token should expire (e.g. \"30d\", 3600).\n * - `JWT_COOKIE_SECURE`: Whether the cookie is sent only over HTTPS. Default: `true` in production.\n * - `JWT_COOKIE_HTTP_ONLY`: Whether the cookie is HTTP-only. Default: `true`.\n * - `JWT_COOKIE_SAME_SITE`: Can be \"lax\", \"strict\", or \"none\". Defaults to \"lax\" in dev, \"none\" in prod.\n *\n * ⚠️ Values passed here take precedence over environment variables.\n */\n jwt?: {\n /** Secret key used for signing and verifying JWT tokens */\n secret?: string;\n /**\n * Duration after which the JWT token expires.\n * Accepts either a duration string (e.g. \"30d\", \"1h\") or a number in milliseconds.\n * Defaults to \"30d\" if not provided.\n */\n expiresIn?: MsDuration | number;\n\n /**\n * Configuration for the JWT cookie sent to the client\n */\n cookie?: {\n /**\n * Whether the cookie should be marked as secure (sent only over HTTPS).\n * Defaults to `true` in production and `false` in development.\n */\n secure?: boolean;\n\n /**\n * Whether the cookie should be marked as HTTP-only.\n * Default is `true` to prevent access via JavaScript.\n */\n httpOnly?: boolean;\n\n /**\n * Controls the SameSite attribute of the cookie.\n * Defaults to \"none\" in production and \"lax\" in development.\n * Options: \"lax\" | \"strict\" | \"none\"\n */\n sameSite?: \"lax\" | \"strict\" | \"none\";\n };\n };\n };\n /** Allows to customize and toggle the built-in validation, by default it is set to `false`. If true is passed it will use validation with the default resolver set to `class-validator` if you intend to change the resolver to `zod` do the following:\n *\n *```ts\n * // src/app.ts\n * import arkos from 'arkos'\n *\n * arkos.init({\n * validation: {\n * resolver: \"zod\"\n * }\n * })\n * ```\n *\n * @See [www.arkosjs.com/docs/core-concepts/request-data-validation](https://www.arkosjs.com/docs/core-concepts/request-data-validation) for more details.\n */\n validation?:\n | {\n resolver?: \"class-validator\";\n /**\n * ValidatorOptions to used while validating request data.\n *\n * **Default**:\n * ```ts\n * {\n * whitelist: true\n * }\n * ```\n */\n validationOptions?: ValidatorOptions;\n }\n | {\n resolver?: \"zod\";\n validationOptions?: Record<string, any>;\n };\n /**\n * Defines file upload configurations\n *\n * See [www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations](https://www.arkosjs.com/docs/core-concepts/file-upload#costum-configurations)\n */\n fileUpload?: {\n /**\n * Defiens the base file upload directory, default is set to /uploads (on root directory)\n *\n * When setting up a path dir always now that root directory will be the starting reference.\n *\n * #### Example\n * passing `../my-arkos-uploaded-files`\n *\n * Will save uploaded files one level outside the root dir inside `my-arkos-uploaded-files`\n *\n * NB: You must be aware of permissions on your server to acess files outside your project directory.\n *\n */\n baseUploadDir?: string;\n /**\n * Changes the default `/api/uploads` base route for accessing file upload route.\n *\n * #### IMPORTANT\n * Changing this will not affect the `baseUploadDir` folder. You can\n * pass here `/api/files/my-user-files` and `baseUploadDir` be `/uploaded-files`.\n *\n */\n baseRoute?: string;\n /**\n * Defines options for `express.static(somePath, someOptions)`\n *\n * #### Default:\n *\n * ```ts\n *{\n maxAge: \"1y\",\n etag: true,\n lastModified: true,\n dotfiles: \"ignore\",\n fallthrough: true,\n index: false,\n cacheControl: true,\n }\n * ```\n * \n * By passing your custom options have in mind that it\n * will be deepmerged with the default.\n * \n * Visit [https://expressjs.com/en/4x/api.html#express.static](https://expressjs.com/en/4x/api.html#express.static) for more understanding.\n * \n */\n expressStaticOptions?: Parameters<typeof express.static>[1];\n /**\n * Defines upload restrictions for each file type: image, video, document or other.\n *\n * #### Important:\n * Passing an object without overriding everything will only cause it\n * to be deepmerged with the default options.\n *\n * See [www.arkosjs.com/docs/api-reference/default-supported-upload-files](https://www.arkosjs.com/docs/api-reference/default-supported-upload-files) for detailed explanation about default values.\n * ```\n */\n restrictions?: {\n images?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n videos?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n documents?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n files?: {\n maxCount?: number;\n maxSize?: number;\n supportedFilesRegex?: RegExp;\n };\n };\n };\n /**\n * Allows to specify the request rate limit for all endpoints.\n * \n * #### Default\n *```ts\n *{\n windowMs: 60 * 1000,\n limit: 1000,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n }\n ```\n * \n * Passing an object not overriding all the default options will only\n * cause it to be deepmerged and not actually replace with empty fields\n * \n * This is are the options used on the `express-rate-limit` npm package used on epxress. read more about [https://www.npmjs.com/package/express-rate-limit](https://www.npmjs.com/package/express-rate-limit)\n */\n globalRequestRateLimitOptions?: Partial<RateLimitOptions>;\n /**\n * Defines options for the built-in express.json() middleware\n * Nothing is passed by default.\n */\n jsonBodyParserOptions?: Parameters<typeof express.json>[0];\n /**\n * Allows to pass paremeters to cookieParser from npm package cookie-parser\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/cookie-parser](https://www.npmjs.com/package/cookie-parser) for further details.\n */\n cookieParserParameters?: Parameters<typeof cookieParser>;\n /**\n * Allows to define options for npm package compression\n * Nothing is passed by default.\n *\n * See [www.npmjs.com/package/compression](https://www.npmjs.com/package/compression) for further details.\n */\n compressionOptions?: compression.CompressionOptions;\n /**\n * Options to define how query must be parsed.\n *\n * #### for example:\n * ```\n * GET /api/product?saleId=null\n * ```\n *\n * Normally would parsed to { saleId: \"null\" } so query parser\n * trough setting option `parseNull` will transform { saleId: null }\n * \n * #### Default:\n * \n * {\n parseNull: true,\n parseUndefined: true,\n parseBoolean: true,\n }\n * \n * parseNumber may convert fields that are string but you only passed\n * numbers to query pay attention to this.\n * \n * Soon a feature to converted the query to the end prisma type will be added.\n */\n queryParserOptions?: QueryParserOptions;\n /**\n * Configuration for CORS (Cross-Origin Resource Sharing).\n *\n * @property {string | string[] | \"all\"} [allowedOrigins] - List of allowed origins. If set to `\"all\"`, all origins are accepted.\n * @property {import('cors').CorsOptions} [options] - Additional CORS options passed directly to the `cors` middleware.\n * @property {import('cors').CorsOptionsDelegate} [customMiddleware] - A custom middleware function that overrides the default behavior.\n *\n * @remarks\n * If `customMiddleware` is provided, both `allowedOrigins` and `options` will be ignored in favor of the custom logic.\n *\n * See https://www.npmjs.com/package/cors\n */\n cors?: {\n /**\n * Defines allowed origins to acess the API.\n */\n allowedOrigins?: string | string[] | \"*\";\n options?: cors.CorsOptions;\n /**\n * If you would like to override the entire middleware\n *\n * see\n */\n customHandler?: cors.CorsOptionsDelegate;\n };\n /**\n * Defines express/arkos middlewares configurations\n */\n middlewares?: {\n /**\n * Allows to add an array of custom express middlewares into the default middleware stack.\n *\n * **Tip**: If you would like to acess the express app before everthing use `configureApp` and pass a function.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order](https://www.arkosjs.com/docs/advanced-guide/replace-or-disable-built-in-middlewares#middleware-execution-order)\n *\n * **Note**: If you want to use custom global error handler middleware use `middlewares.replace.globalErrorHandler`.\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.RequestHandler[];\n /**\n * An array containing a list of defaults middlewares to be disabled\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n *\n */\n disable?: (\n | \"compression\"\n | \"global-rate-limit\"\n | \"auth-rate-limit\"\n | \"cors\"\n | \"express-json\"\n | \"cookie-parser\"\n | \"query-parser\"\n | \"request-logger\"\n | \"global-error-handler\"\n )[];\n /**\n * Allows you to replace each of the built-in middlewares with your own implementation\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default compression middleware\n */\n compression?: express.RequestHandler;\n /**\n * Replace the default global rate limit middleware\n */\n globalRateLimit?: express.RequestHandler;\n /**\n * Replace the default authentication rate limit middleware\n */\n authRateLimit?: express.RequestHandler;\n /**\n * Replace the default CORS middleware\n */\n cors?: express.RequestHandler;\n /**\n * Replace the default JSON body parser middleware\n */\n expressJson?: express.RequestHandler;\n /**\n * Replace the default cookie parser middleware\n */\n cookieParser?: express.RequestHandler;\n /**\n * Replace the default query parser middleware\n */\n queryParser?: express.RequestHandler;\n /**\n * Replace the default request logger middleware\n */\n requestLogger?: express.RequestHandler;\n /**\n * Replace the default global error handler middleware\n */\n globalErrorHandler?: express.ErrorRequestHandler;\n };\n };\n /**\n * Defines express/arkos routers configurations\n */\n routers?: {\n /**\n * Strict mode configuration for routing security\n *\n * @default false\n * - all CRUD + Auth (if using auth) endpoits are enabled and avialable by default.\n *\n * When enabled:\n * - If `true`: All CRUD endpoints start disabled and must be explicitly enabled\n * in each model's router configuration\n * - If `'no-bulk'`: Bulk operations (createMany, updateMany, deleteMany) are disabled\n * by default, while individual operations can be enabled per model\n *\n * This provides enhanced security by ensuring no routes are accidentally exposed.\n * Use this in production environments to follow the principle of least privilege.\n *\n * See documentation: https://www.arkosjs.com/docs/guide/security#strict-mode\n */\n strict?: boolean | \"no-bulk\";\n /**\n * Allows to add an array of custom express routers into the default middleware/router stack.\n *\n * **Where will these be placed?**: see [www.arkosjs.com/docs/advanced-guide/adding-custom-routers](https://www.arkosjs.com/docs/advanced-guide/adding-custom-routers)\n *\n *\n * Read more about The Arkos Middleware Stack at [www.arkosjs.com/docs/the-middleware-stack](https://www.arkosjs.com/docs/the-middleware-stack) for in-depth details.\n */\n additional?: express.Router[];\n disable?: (\n | \"auth-router\"\n | \"prisma-models-router\"\n | \"file-upload\"\n | \"welcome-endpoint\"\n )[];\n /**\n * Allows you to replace each of the built-in routers with your own implementation.\n *\n * **Note**: Doing this you will lose all default middleware chaining, auth control, handlers from the specific router.\n *\n * **Tip**: I you want to disable some prisma models specific endpoint\n * see [www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints](https://www.arkosjs.com/docs/guide/adding-custom-routers#disabling-auto-generated-endpoints)\n *\n * **Caution**: Be careful with this because you may endup breaking your entire application.\n */\n replace?: {\n /**\n * Replace the default authentication router\n * @param config The original Arkos configuration\n * @returns A router handling authentication endpoints\n */\n authRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default Prisma models router\n * @param config The original Arkos configuration\n * @returns A router handling Prisma model endpoints\n */\n prismaModelsRouter?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default file upload router\n * @param config The original Arkos configuration\n * @returns A router handling file upload endpoints\n */\n fileUpload?: (\n config: ArkosConfig\n ) => express.Router | Promise<express.Router>;\n /**\n * Replace the default welcome endpoint handler\n * @param req Express request object\n * @param res Express response object\n * @param next Express next function\n */\n welcomeEndpoint?: express.RequestHandler;\n };\n };\n /**\n * Gives acess to the underlying express app so that you can add custom configurations beyong **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `app.listen` for you.\n *\n * If you want to call `app.listen` by yourself pass port as `undefined` and then use the return app from `arkos.init()`.\n *\n * See how to call `app.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself](https://www.arkosjs.com/docs/guide/accessing-the-express-app#calling-applisten-by-yourself)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app](https://www.arkosjs.com/docs/guide/accessing-the-express-app) for further details on the method configureApp.\n *\n * @param {express.Express} app\n * @returns {any}\n */\n configureApp?: (app: express.Express) => Promise<any> | any;\n /**\n * Gives access to the underlying HTTP server so that you can add custom configurations beyond **Arkos** customization capabilities\n *\n * **Note**: In the end **Arkos** will call `server.listen` for you.\n *\n * If you want to call `server.listen` by yourself pass port as `undefined` and then use the return server from `arkos.init()`.\n *\n * See how to call `server.listen` correctly [www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#creating-your-own-http-server)\n *\n * See [www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server](https://www.arkosjs.com/docs/guide/accessing-the-express-app#accessing-the-http-server) for further details on the method configureServer.\n *\n * @param {http.Server} server - The HTTP server instance\n * @returns {any}\n */\n configureServer?: (server: http.Server) => Promise<any> | any;\n /**\n * Allows to configure email configurations for sending emails through `emailService`\n *\n * See [www.arkosjs.com/docs/core-concepts/sending-emails](https://www.arkosjs.com/docs/core-concepts/sending-emails)\n */\n email?: {\n /**\n * Email name to used like:\n *\n * John Doe\\<john.doe@gmail.com>\n */\n name?: string;\n /**\n * Your email provider url\n */\n host: string;\n /**\n * Email provider SMTP port, Default is `465`\n */\n port?: number;\n /**\n * If smtp connection must be secure, Default is `true`\n */\n secure?: boolean;\n /**\n * Used to authenticate in your smtp server\n */\n auth: {\n /**\n * Email used for auth as well as sending emails\n */\n user: string;\n /**\n * Your SMTP password\n */\n pass: string;\n };\n } & Parameters<typeof nodemailer.createTransport>[0];\n /**\n * Defines Swagger and OpenApi specifications for auto generating swagger documentation UI using whether it is Prisma Schemas, Class-validator DTOs, Zod Schemas or JSON-Schemas.\n *\n * **Important**: Is worth mentioning that this works alongside `@scalar/express-api-reference` npm package, you define it's ApiReferenceConfiguration under ``. also consider checking the package documentation at []\n *\n * **Usage**\n *\n * ```ts\n * // src/app.ts\n *\n * import arkos from \"arkos\"\n *\n * arkos.init({\n * // other configs\n * swagger: {\n * mode: \"zod\",\n * options: {\n * defintion: {\n * info: {\n * openapi: \"3.0.0\",\n * title: \"API Generated By Arkos.js\",\n * description: \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n * }\n * }\n * }\n * }\n * })\n * ```\n * @see {@link https://www.arkosjs.com/docs/core-concepts/swagger-api-documentation}\n */\n swagger?: {\n /**\n * By default Arkos will disable API Documentation when the project is built `npm run build`, it does not matter what node environment is set. If you want to use it even after the `arkos build` command just set this to `true`.\n * */\n enableAfterBuild?: boolean;\n /**\n * Endpoint where the Swagger UI will be available.\n *\n * @default \"/api/api-docs\"\n */\n endpoint?: string;\n /**\n * Determines how your API schemas should be generated.\n *\n * - \"prisma\": Generates schemas based on Prisma models\n * - \"class-validator\": Uses class-validator and class-transformer DTO classes\n * - \"zod\": Uses OpenAPI-compliant schemas directly\n */\n mode: \"prisma\" | \"class-validator\" | \"zod\";\n /**\n * Allows `Arkos.js` to fallback to prisma schema and use them as json schema for defining request body and response data\n * when a given zod Schema or class-validator Class is not found to be transformed to json schema.\n *\n * @default false\n */\n strict?: boolean;\n /**\n * Defines your swagger configurations\n */\n options?: {\n /**\n * Swagger definition according to OpenAPI Specification.\n */\n definition?: {\n /**\n * OpenAPI version.\n *\n * @default \"3.0.0\"\n */\n openapi?: string;\n\n /**\n * Information about your API.\n */\n info?: {\n /**\n * Title of the API documentation.\n *\n *\n * @example \"My API\"\n *\n * @default \"API Generated By Arkos.js\"\n */\n title?: string;\n\n /**\n * Version of the API.\n *\n * @example \"1.0.0\"\n */\n version?: string;\n\n /**\n * Description of the API.\n *\n * @default \"This API was automatically generated by Arkos.js read more about at www.arkosjs.com\"\n */\n description?: string;\n };\n\n /**\n * Server configurations for the API.\n *\n * @default [{ url: \"http://localhost:8000\", description: \"Development server\" }]\n *\n * This can be overridden automatically by Arkos based on CLI, .env, or `arkos.init()`.\n */\n servers?: {\n /**\n * Base URL of the server.\n *\n * @example \"http://localhost:8000\"\n */\n url: string;\n\n /**\n * Human-readable description of the server.\n *\n * @example \"Development Server\"\n */\n description?: string;\n }[];\n /**\n * Allows adding more paths for your OpenAPI documentation\n *\n * */\n paths?: OpenAPIV3.PathsObject;\n /**\n * (Optional) Additional metadata such as terms of service, contact, or license.\n *\n * See: https://swagger.io/specification/#infoObject\n */\n termsOfService?: string;\n contact?: {\n name?: string;\n url?: string;\n email?: string;\n };\n license?: {\n name: string;\n url?: string;\n };\n\n /**\n * Tags to group and describe endpoints.\n */\n tags?: {\n name: string;\n description?: string;\n }[];\n\n /**\n * Security definitions (e.g., Bearer Auth).\n */\n components?: {\n securitySchemes?: Record<string, any>;\n schemas?: Record<string, any>;\n };\n\n /**\n * Global security requirements.\n */\n security?: Array<Record<string, string[]>>;\n };\n\n /**\n * Glob patterns defining where Swagger should look for API route definitions and comments.\n *\n * @default \n * ```ts\n * [\"./src/routers/*.router.{ts,js}\", \"./src/modules/**\\/*.router.{ts,js}\"]\n ```\n *\n * Adjust depending on TypeScript or JavaScript usage.\n */\n apis?: string[];\n\n /**\n * Enables deep linking in the Swagger UI.\n *\n * @default true\n */\n deepLinking?: boolean;\n\n /**\n * Enable/disable the \"Try it out\" button globally.\n *\n * @default true\n */\n tryItOutEnabled?: boolean;\n\n /**\n * Whether to persist authorization data across page reloads.\n *\n * @default false\n */\n persistAuthorization?: boolean;\n };\n /**\n * Custom `@scalar/express-api-reference` package options.\n *\n * @see {@link https://guides.scalar.com/scalar/scalar-api-references/integrations/express}\n */\n scalarApiReferenceConfiguration?: Partial<ApiReferenceConfiguration>;\n };\n};\n"]}
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=auth.js.map
@@ -1 +1,11 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AuthPermissionAction=void 0;var AuthPermissionAction;(function(e){e.Create="Create",e.View="View",e.Update="Update",e.Delete="Delete"})(AuthPermissionAction||(exports.AuthPermissionAction=AuthPermissionAction={}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthPermissionAction = void 0;
4
+ var AuthPermissionAction;
5
+ (function (AuthPermissionAction) {
6
+ AuthPermissionAction["Create"] = "Create";
7
+ AuthPermissionAction["View"] = "View";
8
+ AuthPermissionAction["Update"] = "Update";
9
+ AuthPermissionAction["Delete"] = "Delete";
10
+ })(AuthPermissionAction || (exports.AuthPermissionAction = AuthPermissionAction = {}));
11
+ //# sourceMappingURL=index.js.map
@@ -1 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=router-config.js.map
@@ -1 +1,9 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const arkosEnv={JWT_SECRET:"13a9279eedb286f756212511267152e9585055809ec0606ea9f7eb98a87660c1616fbd39c44d4238a82f29df90b529e24bfdf72a480d1149d79c991c863a22b5ae0fb3ae6f5323bfd6664faef99792637477c38da488e7aa0d39b83ba99aba8e8a20efde7fd5c7ba21a6c938e17a9f99f73226dc61e89cd63f159257841194323f100d1a49b88ce4fdcdf2b066a5f32f88ee12f6487b55b4b5687d7c0caffdd8524e2adc4b941cf52e948f5b330f527eb1354341c876eed12dfa92cef3c341d030d05e6beb1e0a7f6d3e08e7b1aac045130457fd3a53ee469fecdd20fdd2c7a6a72b07cbcb1157c5b1cc581e6767bea32be8e125016a48951e85c7bdb961d9c9fab28444499ce063664fe0bd1a05d60294323bdd69af6d6ff1a2533dac8d4a869f76dbc746ee12f144e0af41029f620471817843140c23d036e731f3ebee21a70ff1549e97486fdf9cbef132ff2ced59fde9be35dd04b358c9a25ec4fd9cc0e36dae651e626d8c13b0c6d2a21f237517a05059680173e71817597062c792ea9c66030ca0d8ed82987e29189947692a0be5fffac4c988ca33f14ce96349661ef850dbff6909c7797676c90a5e47655346f59759482ef8a3a948e97e30f889bd4571610fd19e8ea4818651d37f6529cf32f0fc805bc053e911f0fe96f52b4420d54bd1f40739a95f5853b036c86ab9a51bed57fa9bd48607b5302e88db00900adf",JWT_EXPIRES_IN:"30d",PRISMA_SCHEMA_PATH:"./prisma/schema"};exports.default=arkosEnv;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const arkosEnv = {
4
+ JWT_SECRET: "13a9279eedb286f756212511267152e9585055809ec0606ea9f7eb98a87660c1616fbd39c44d4238a82f29df90b529e24bfdf72a480d1149d79c991c863a22b5ae0fb3ae6f5323bfd6664faef99792637477c38da488e7aa0d39b83ba99aba8e8a20efde7fd5c7ba21a6c938e17a9f99f73226dc61e89cd63f159257841194323f100d1a49b88ce4fdcdf2b066a5f32f88ee12f6487b55b4b5687d7c0caffdd8524e2adc4b941cf52e948f5b330f527eb1354341c876eed12dfa92cef3c341d030d05e6beb1e0a7f6d3e08e7b1aac045130457fd3a53ee469fecdd20fdd2c7a6a72b07cbcb1157c5b1cc581e6767bea32be8e125016a48951e85c7bdb961d9c9fab28444499ce063664fe0bd1a05d60294323bdd69af6d6ff1a2533dac8d4a869f76dbc746ee12f144e0af41029f620471817843140c23d036e731f3ebee21a70ff1549e97486fdf9cbef132ff2ced59fde9be35dd04b358c9a25ec4fd9cc0e36dae651e626d8c13b0c6d2a21f237517a05059680173e71817597062c792ea9c66030ca0d8ed82987e29189947692a0be5fffac4c988ca33f14ce96349661ef850dbff6909c7797676c90a5e47655346f59759482ef8a3a948e97e30f889bd4571610fd19e8ea4818651d37f6529cf32f0fc805bc053e911f0fe96f52b4420d54bd1f40739a95f5853b036c86ab9a51bed57fa9bd48607b5302e88db00900adf",
5
+ JWT_EXPIRES_IN: "30d",
6
+ PRISMA_SCHEMA_PATH: `./prisma/schema`,
7
+ };
8
+ exports.default = arkosEnv;
9
+ //# sourceMappingURL=arkos-env.js.map
@@ -1,5 +1,214 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildCommand=buildCommand;const path_1=__importDefault(require("path")),fs_1=__importDefault(require("fs")),child_process_1=require("child_process"),fs_helpers_1=require("../helpers/fs.helpers"),dotenv_helpers_1=require("../dotenv.helpers"),cli_helpers_1=require("./utils/cli.helpers"),global_helpers_1=require("../helpers/global.helpers"),sheu_1=__importDefault(require("../sheu")),BUILD_DIR=".build",MODULE_TYPES=["cjs","esm"];function buildCommand(e={}){const s=(0,fs_helpers_1.getUserFileExtension)();process.env.NODE_ENV="production",process.env.NODE_ENV="true";const t=(0,dotenv_helpers_1.loadEnvironmentVariables)(),n=validateModuleType(e.module);try{console.info(` \x1B[1m\x1B[36m Arkos.js ${(0,cli_helpers_1.getVersion)()}\x1B[0m`),console.info(` - Environments: ${(0,fs_helpers_1.fullCleanCwd)(t?.join(", ")||"").replaceAll(`${process.cwd()}/`,"").replaceAll("/","")}`),console.info(`
2
- Creating an optimized production build...`),ensureBuildDir(),s==="ts"?buildTypeScriptProject(e,n):buildJavaScriptProject(e,n);const r=(0,global_helpers_1.detectPackageManagerFromUserAgent)();console.info(`
3
- \x1B[1m\x1B[32m Build complete!\x1B[0m
4
- `),console.info(" \x1B[1mNext step:\x1B[0m"),console.info(` Run it using \x1B[1m\x1B[36m${r} run start\x1B[0m
5
- `)}catch(r){console.info(""),sheu_1.default.error(`Build failed: ${r?.message}`),console.error(r),process.exit(1)}}function validateModuleType(e){if(!e)return"cjs";const s=e.toLowerCase();return s==="cjs"||s==="commonjs"?"cjs":["esm","es","es2020","esnext","module"].includes(s)?"esm":(console.warn(`\u26A0\uFE0F Unrecognized module type "${e}", defaulting to "cjs"`),"cjs")}function ensureBuildDir(){fs_1.default.existsSync(BUILD_DIR)||fs_1.default.mkdirSync(BUILD_DIR,{recursive:!0});for(const e of MODULE_TYPES){const s=path_1.default.join(BUILD_DIR,e);fs_1.default.existsSync(s)||fs_1.default.mkdirSync(s,{recursive:!0})}}function buildTypeScriptProject(e,s){const t=path_1.default.join(process.cwd(),e.config||"tsconfig.json");let n={};try{if(fs_1.default.existsSync(t)){const o=fs_1.default.readFileSync(t,"utf8");n=JSON.parse(o)}}catch(o){console.error("\u274C Error reading tsconfig.json:",o)}const r={...n,compilerOptions:{...n.compilerOptions||{},rootDir:".",outDir:path_1.default.join(`./${BUILD_DIR}`)}},c=path_1.default.join(process.cwd(),"tsconfig.arkos-build.json");fs_1.default.writeFileSync(c,JSON.stringify(r,null,2));try{(0,child_process_1.execSync)(`npx rimraf ${BUILD_DIR} && npx tsc -p ${c}`,{stdio:"inherit",cwd:process.cwd()}),copyAllNonSourceFiles(s,[".ts",".tsx"]),cleanupTempConfig(c)}catch(o){throw cleanupTempConfig(c),o}}function buildJavaScriptProject(e,s){const t=path_1.default.join(BUILD_DIR);try{s==="esm"?((0,child_process_1.execSync)(`npx copyfiles -u 0 "src/**/*.js" "src/**/*.jsx" "src/**/*.mjs" ${t}`,{stdio:"inherit",cwd:process.cwd()}),console.info("Note: .cjs files are skipped in ESM build")):(0,child_process_1.execSync)(`npx copyfiles -u 0 "src/**/*.js" "src/**/*.jsx" "src/**/*.cjs" "src/**/*.mjs" ${t}`,{stdio:"inherit",cwd:process.cwd()}),copyAllNonSourceFiles(s,[".js",".jsx",".mjs",".cjs",".ts",".tsx"]),createModulePackageJson(s)}catch(n){throw console.error("\u274C Error building JavaScript project:",n),n}}function copyAllNonSourceFiles(e,s){const t=path_1.default.join(BUILD_DIR),n="src";try{let r=function(o){if(!fs_1.default.existsSync(o))return;const d=fs_1.default.readdirSync(o);for(const l of d){const a=path_1.default.join(o,l),i=path_1.default.join(t,o.replace(n,""),l),u=fs_1.default.statSync(a);if(u.isDirectory())fs_1.default.existsSync(i)||fs_1.default.mkdirSync(i,{recursive:!0}),r(a);else if(u.isFile()){const p=path_1.default.extname(l).toLowerCase();if(!s.includes(p)){const f=path_1.default.dirname(i);fs_1.default.existsSync(f)||fs_1.default.mkdirSync(f,{recursive:!0}),fs_1.default.copyFileSync(a,i)}}}};r(n);const c=["README.md","LICENSE"];for(const o of c)fs_1.default.existsSync(path_1.default.join(process.cwd(),o))&&fs_1.default.copyFileSync(path_1.default.join(process.cwd(),o),path_1.default.join(t,o))}catch(r){console.warn("Warning: Error copying project files:",r),console.error(r)}}function createModulePackageJson(e){const s=path_1.default.join(process.cwd(),"package.json");if(fs_1.default.existsSync(s))try{const t=JSON.parse(fs_1.default.readFileSync(s,"utf8")),n={name:t.name,version:t.version,description:t.description,main:"index.js",dependencies:t.dependencies};e==="esm"&&(n.type="module");const r=path_1.default.join(BUILD_DIR,e);fs_1.default.writeFileSync(path_1.default.join(r,"package.json"),JSON.stringify(n,null,2))}catch(t){console.warn("Warning: Failed to create module-specific package.json",t)}}function cleanupTempConfig(e){try{fs_1.default.existsSync(e)&&fs_1.default.unlinkSync(e)}catch(s){console.warn("Warning: Error cleaning up temporary config:",s)}}
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildCommand = buildCommand;
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const child_process_1 = require("child_process");
10
+ const fs_helpers_1 = require("../helpers/fs.helpers");
11
+ const dotenv_helpers_1 = require("../dotenv.helpers");
12
+ const cli_helpers_1 = require("./utils/cli.helpers");
13
+ const global_helpers_1 = require("../helpers/global.helpers");
14
+ const sheu_1 = __importDefault(require("../sheu"));
15
+ const BUILD_DIR = ".build";
16
+ const MODULE_TYPES = ["cjs", "esm"];
17
+ function buildCommand(options = {}) {
18
+ const fileExt = (0, fs_helpers_1.getUserFileExtension)();
19
+ process.env.NODE_ENV = "production";
20
+ process.env.NODE_ENV = "true";
21
+ const envFiles = (0, dotenv_helpers_1.loadEnvironmentVariables)();
22
+ const moduleType = validateModuleType(options.module);
23
+ try {
24
+ console.info(` \x1b[1m\x1b[36m Arkos.js ${(0, cli_helpers_1.getVersion)()}\x1b[0m`);
25
+ console.info(` - Environments: ${(0, fs_helpers_1.fullCleanCwd)(envFiles?.join(", ") || "")
26
+ .replaceAll(`${process.cwd()}/`, "")
27
+ .replaceAll("/", "")}`);
28
+ console.info(`\n Creating an optimized production build...`);
29
+ ensureBuildDir();
30
+ if (fileExt === "ts") {
31
+ buildTypeScriptProject(options, moduleType);
32
+ }
33
+ else {
34
+ buildJavaScriptProject(options, moduleType);
35
+ }
36
+ const packageManger = (0, global_helpers_1.detectPackageManagerFromUserAgent)();
37
+ console.info(`\n\x1b[1m\x1b[32m Build complete!\x1b[0m\n`);
38
+ console.info(` \x1b[1mNext step:\x1b[0m`);
39
+ console.info(` Run it using \x1b[1m\x1b[36m${packageManger} run start\x1b[0m\n`);
40
+ }
41
+ catch (err) {
42
+ console.info("");
43
+ sheu_1.default.error(`Build failed: ${err?.message}`);
44
+ console.error(err);
45
+ process.exit(1);
46
+ }
47
+ }
48
+ function validateModuleType(moduleType) {
49
+ if (!moduleType)
50
+ return "cjs";
51
+ const normalizedType = moduleType.toLowerCase();
52
+ if (normalizedType === "cjs" || normalizedType === "commonjs") {
53
+ return "cjs";
54
+ }
55
+ else if (["esm", "es", "es2020", "esnext", "module"].includes(normalizedType)) {
56
+ return "esm";
57
+ }
58
+ console.warn(`⚠️ Unrecognized module type "${moduleType}", defaulting to "cjs"`);
59
+ return "cjs";
60
+ }
61
+ function ensureBuildDir() {
62
+ if (!fs_1.default.existsSync(BUILD_DIR)) {
63
+ fs_1.default.mkdirSync(BUILD_DIR, { recursive: true });
64
+ }
65
+ for (const moduleType of MODULE_TYPES) {
66
+ const moduleDir = path_1.default.join(BUILD_DIR, moduleType);
67
+ if (!fs_1.default.existsSync(moduleDir)) {
68
+ fs_1.default.mkdirSync(moduleDir, { recursive: true });
69
+ }
70
+ }
71
+ }
72
+ function buildTypeScriptProject(options, moduleType) {
73
+ const tsconfigPath = path_1.default.join(process.cwd(), options.config || "tsconfig.json");
74
+ let tsconfig = {};
75
+ try {
76
+ if (fs_1.default.existsSync(tsconfigPath)) {
77
+ const tsconfigContent = fs_1.default.readFileSync(tsconfigPath, "utf8");
78
+ tsconfig = JSON.parse(tsconfigContent);
79
+ }
80
+ }
81
+ catch (error) {
82
+ console.error("❌ Error reading tsconfig.json:", error);
83
+ }
84
+ const tempTsconfig = {
85
+ ...tsconfig,
86
+ compilerOptions: {
87
+ ...(tsconfig.compilerOptions || {}),
88
+ rootDir: ".",
89
+ outDir: path_1.default.join(`./${BUILD_DIR}`),
90
+ },
91
+ };
92
+ const tempTsconfigPath = path_1.default.join(process.cwd(), `tsconfig.arkos-build.json`);
93
+ fs_1.default.writeFileSync(tempTsconfigPath, JSON.stringify(tempTsconfig, null, 2));
94
+ try {
95
+ (0, child_process_1.execSync)(`npx rimraf ${BUILD_DIR} && npx tsc -p ${tempTsconfigPath}`, {
96
+ stdio: "inherit",
97
+ cwd: process.cwd(),
98
+ });
99
+ copyAllNonSourceFiles(moduleType, [".ts", ".tsx"]);
100
+ cleanupTempConfig(tempTsconfigPath);
101
+ }
102
+ catch (error) {
103
+ cleanupTempConfig(tempTsconfigPath);
104
+ throw error;
105
+ }
106
+ }
107
+ function buildJavaScriptProject(_, moduleType) {
108
+ const targetDir = path_1.default.join(BUILD_DIR);
109
+ try {
110
+ if (moduleType === "esm") {
111
+ (0, child_process_1.execSync)(`npx copyfiles -u 0 "src/**/*.js" "src/**/*.jsx" "src/**/*.mjs" ${targetDir}`, {
112
+ stdio: "inherit",
113
+ cwd: process.cwd(),
114
+ });
115
+ console.info("Note: .cjs files are skipped in ESM build");
116
+ }
117
+ else {
118
+ (0, child_process_1.execSync)(`npx copyfiles -u 0 "src/**/*.js" "src/**/*.jsx" "src/**/*.cjs" "src/**/*.mjs" ${targetDir}`, {
119
+ stdio: "inherit",
120
+ cwd: process.cwd(),
121
+ });
122
+ }
123
+ copyAllNonSourceFiles(moduleType, [
124
+ ".js",
125
+ ".jsx",
126
+ ".mjs",
127
+ ".cjs",
128
+ ".ts",
129
+ ".tsx",
130
+ ]);
131
+ createModulePackageJson(moduleType);
132
+ }
133
+ catch (error) {
134
+ console.error("❌ Error building JavaScript project:", error);
135
+ throw error;
136
+ }
137
+ }
138
+ function copyAllNonSourceFiles(_, skipExtensions) {
139
+ const targetDir = path_1.default.join(BUILD_DIR);
140
+ const sourceDir = "src";
141
+ try {
142
+ function copyDirRecursive(dir) {
143
+ if (!fs_1.default.existsSync(dir))
144
+ return;
145
+ const items = fs_1.default.readdirSync(dir);
146
+ for (const item of items) {
147
+ const sourcePath = path_1.default.join(dir, item);
148
+ const targetPath = path_1.default.join(targetDir, dir.replace(sourceDir, ""), item);
149
+ const stats = fs_1.default.statSync(sourcePath);
150
+ if (stats.isDirectory()) {
151
+ if (!fs_1.default.existsSync(targetPath)) {
152
+ fs_1.default.mkdirSync(targetPath, { recursive: true });
153
+ }
154
+ copyDirRecursive(sourcePath);
155
+ }
156
+ else if (stats.isFile()) {
157
+ const ext = path_1.default.extname(item).toLowerCase();
158
+ if (!skipExtensions.includes(ext)) {
159
+ const targetDir = path_1.default.dirname(targetPath);
160
+ if (!fs_1.default.existsSync(targetDir)) {
161
+ fs_1.default.mkdirSync(targetDir, { recursive: true });
162
+ }
163
+ fs_1.default.copyFileSync(sourcePath, targetPath);
164
+ }
165
+ }
166
+ }
167
+ }
168
+ copyDirRecursive(sourceDir);
169
+ const rootFilesToCopy = ["README.md", "LICENSE"];
170
+ for (const file of rootFilesToCopy) {
171
+ if (fs_1.default.existsSync(path_1.default.join(process.cwd(), file))) {
172
+ fs_1.default.copyFileSync(path_1.default.join(process.cwd(), file), path_1.default.join(targetDir, file));
173
+ }
174
+ }
175
+ }
176
+ catch (error) {
177
+ console.warn("Warning: Error copying project files:", error);
178
+ console.error(error);
179
+ }
180
+ }
181
+ function createModulePackageJson(moduleType) {
182
+ const packageJsonPath = path_1.default.join(process.cwd(), "package.json");
183
+ if (!fs_1.default.existsSync(packageJsonPath)) {
184
+ return;
185
+ }
186
+ try {
187
+ const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf8"));
188
+ const buildPackageJson = {
189
+ name: packageJson.name,
190
+ version: packageJson.version,
191
+ description: packageJson.description,
192
+ main: "index.js",
193
+ dependencies: packageJson.dependencies,
194
+ };
195
+ if (moduleType === "esm") {
196
+ buildPackageJson.type = "module";
197
+ }
198
+ const targetDir = path_1.default.join(BUILD_DIR, moduleType);
199
+ fs_1.default.writeFileSync(path_1.default.join(targetDir, "package.json"), JSON.stringify(buildPackageJson, null, 2));
200
+ }
201
+ catch (error) {
202
+ console.warn("Warning: Failed to create module-specific package.json", error);
203
+ }
204
+ }
205
+ function cleanupTempConfig(configPath) {
206
+ try {
207
+ if (fs_1.default.existsSync(configPath))
208
+ fs_1.default.unlinkSync(configPath);
209
+ }
210
+ catch (error) {
211
+ console.warn("Warning: Error cleaning up temporary config:", error);
212
+ }
213
+ }
214
+ //# sourceMappingURL=build.js.map
@@ -1,3 +1,154 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.devCommand=devCommand,exports.killDevelopmentServerChildProcess=killDevelopmentServerChildProcess;const child_process_1=require("child_process"),chokidar_1=__importDefault(require("chokidar")),fs_helpers_1=require("../helpers/fs.helpers"),cli_helpers_1=require("./utils/cli.helpers"),dotenv_helpers_1=require("../dotenv.helpers"),fs_1=__importDefault(require("fs")),path_1=__importDefault(require("path")),sheu_1=__importDefault(require("../sheu")),port_and_host_allocator_1=__importDefault(require("../features/port-and-host-allocator"));let child=null,envFiles;async function devCommand(r={}){process.env.NODE_ENV="development",envFiles=(0,dotenv_helpers_1.loadEnvironmentVariables)(),child=null;let o=null;try{const{port:n,host:p}=r;let i=!1,d=new Set;const f=(0,fs_helpers_1.getUserFileExtension)(),l=path_1.default.resolve(process.cwd(),`src/app.${f}`);fs_1.default.existsSync(l)||(console.error(`Could not find application entry point at ${l}`),process.exit(1));const h=()=>({NODE_ENV:"development",...process.env,...n&&{CLI_PORT:n},...p&&{CLI_HOST:p}}),c=()=>{child&&(child.kill(),child=null);const e=h();f==="ts"?child=(0,child_process_1.spawn)("npx",["tsx-strict","--watch",l],{stdio:"inherit",env:e,shell:!0}):child=(0,child_process_1.spawn)("npx",["tsx-strict","--no-type-check","--watch",l],{stdio:"inherit",env:e,shell:!0}),child&&(child.on("error",t=>{console.error("Failed to start server:",t)}),child.on("exit",(t,s)=>{!i&&s!=="SIGTERM"&&s!=="SIGINT"&&(console.info(`Server exited with code ${t}, restarting...`),c())}))},m=(e,t)=>{t&&d.add(t),o&&clearTimeout(o);const u=new Date().toTimeString().split(" ")[0];i=!0,child&&(child.kill(),child=null),o=setTimeout(()=>{sheu_1.default.info(`\x1B[90m${u}\x1B[0m Restarting: ${e.toLowerCase()}`),c(),i=!1,o=null,t&&d.delete(t)},1e3)},x=()=>{const e=chokidar_1.default.watch((0,fs_helpers_1.fullCleanCwd)(envFiles?.join(",")||"").replaceAll("/","").split(",")||[],{ignoreInitial:!0,persistent:!0});return e.on("all",(t,s)=>{try{envFiles=(0,dotenv_helpers_1.loadEnvironmentVariables)(),m("Environment files changed","env-files")}catch(u){console.error(`Error reloading ${s}:`,u)}}),e};c();const v=x(),E=h(),_=await port_and_host_allocator_1.default.getHostAndAvailablePort(E,{logWarning:!0});console.info(`
2
- \x1B[1m\x1B[36m Arkos.js ${(0,cli_helpers_1.getVersion)()}\x1B[0m`),console.info(` - Local: http://${_?.host}:${_?.port}`),console.info(` - Environments: ${(0,fs_helpers_1.fullCleanCwd)(envFiles?.join(", ")||"").replaceAll(`${process.cwd()}/`,"").replaceAll("/","")}
3
- `);const a=()=>{o&&clearTimeout(o),v&&v.close(),child&&(child.kill("SIGTERM"),setTimeout(()=>{child&&!child.killed&&child.kill("SIGKILL")},5e3)),process.exit(0)};process.on("SIGINT",a),process.on("SIGTERM",a),process.on("uncaughtException",e=>{console.error("Uncaught Exception:",e),a()})}catch(n){console.error("Development server failed to start:",n),child&&(child?.kill?.(),child=null),process.exit(1)}}function killDevelopmentServerChildProcess(){child?.kill?.(),child=null}
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.devCommand = devCommand;
7
+ exports.killDevelopmentServerChildProcess = killDevelopmentServerChildProcess;
8
+ const child_process_1 = require("child_process");
9
+ const chokidar_1 = __importDefault(require("chokidar"));
10
+ const fs_helpers_1 = require("../helpers/fs.helpers");
11
+ const cli_helpers_1 = require("./utils/cli.helpers");
12
+ const dotenv_helpers_1 = require("../dotenv.helpers");
13
+ const fs_1 = __importDefault(require("fs"));
14
+ const path_1 = __importDefault(require("path"));
15
+ const sheu_1 = __importDefault(require("../sheu"));
16
+ const port_and_host_allocator_1 = __importDefault(require("../features/port-and-host-allocator"));
17
+ let child = null;
18
+ let envFiles;
19
+ async function devCommand(options = {}) {
20
+ process.env.NODE_ENV = "development";
21
+ envFiles = (0, dotenv_helpers_1.loadEnvironmentVariables)();
22
+ child = null;
23
+ let restartTimeout = null;
24
+ try {
25
+ const { port, host } = options;
26
+ let isRestarting = false;
27
+ let restartingFiles = new Set();
28
+ const fileExt = (0, fs_helpers_1.getUserFileExtension)();
29
+ const entryPoint = path_1.default.resolve(process.cwd(), `src/app.${fileExt}`);
30
+ if (!fs_1.default.existsSync(entryPoint)) {
31
+ console.error(`Could not find application entry point at ${entryPoint}`);
32
+ process.exit(1);
33
+ }
34
+ const getEnv = () => ({
35
+ NODE_ENV: "development",
36
+ ...process.env,
37
+ ...(port && { CLI_PORT: port }),
38
+ ...(host && { CLI_HOST: host }),
39
+ });
40
+ const startServer = () => {
41
+ if (child) {
42
+ child.kill();
43
+ child = null;
44
+ }
45
+ const env = getEnv();
46
+ if (fileExt === "ts") {
47
+ child = (0, child_process_1.spawn)("npx", ["tsx-strict", "--watch", entryPoint], {
48
+ stdio: "inherit",
49
+ env,
50
+ shell: true,
51
+ });
52
+ }
53
+ else {
54
+ child = (0, child_process_1.spawn)("npx", ["tsx-strict", "--no-type-check", "--watch", entryPoint], {
55
+ stdio: "inherit",
56
+ env,
57
+ shell: true,
58
+ });
59
+ }
60
+ if (child) {
61
+ child.on("error", (error) => {
62
+ console.error("Failed to start server:", error);
63
+ });
64
+ child.on("exit", (code, signal) => {
65
+ if (!isRestarting && signal !== "SIGTERM" && signal !== "SIGINT") {
66
+ console.info(`Server exited with code ${code}, restarting...`);
67
+ startServer();
68
+ }
69
+ });
70
+ }
71
+ };
72
+ const scheduleRestart = (reason, filePath) => {
73
+ if (filePath)
74
+ restartingFiles.add(filePath);
75
+ if (restartTimeout)
76
+ clearTimeout(restartTimeout);
77
+ const now = new Date();
78
+ const time = now.toTimeString().split(" ")[0];
79
+ isRestarting = true;
80
+ if (child) {
81
+ child.kill();
82
+ child = null;
83
+ }
84
+ restartTimeout = setTimeout(() => {
85
+ sheu_1.default.info(`\x1b[90m${time}\x1b[0m Restarting: ${reason.toLowerCase()}`);
86
+ startServer();
87
+ isRestarting = false;
88
+ restartTimeout = null;
89
+ if (filePath)
90
+ restartingFiles.delete(filePath);
91
+ }, 1000);
92
+ };
93
+ const setupEnvWatcher = () => {
94
+ const envWatcher = chokidar_1.default.watch((0, fs_helpers_1.fullCleanCwd)(envFiles?.join(",") || "")
95
+ .replaceAll("/", "")
96
+ .split(",") || [], {
97
+ ignoreInitial: true,
98
+ persistent: true,
99
+ });
100
+ envWatcher.on("all", (_, filePath) => {
101
+ try {
102
+ envFiles = (0, dotenv_helpers_1.loadEnvironmentVariables)();
103
+ scheduleRestart("Environment files changed", "env-files");
104
+ }
105
+ catch (error) {
106
+ console.error(`Error reloading ${filePath}:`, error);
107
+ }
108
+ });
109
+ return envWatcher;
110
+ };
111
+ startServer();
112
+ const envWatcher = setupEnvWatcher();
113
+ const env = getEnv();
114
+ const hostAndPort = await port_and_host_allocator_1.default.getHostAndAvailablePort(env, { logWarning: true });
115
+ console.info(`\n \x1b[1m\x1b[36m Arkos.js ${(0, cli_helpers_1.getVersion)()}\x1b[0m`);
116
+ console.info(` - Local: http://${hostAndPort?.host}:${hostAndPort?.port}`);
117
+ console.info(` - Environments: ${(0, fs_helpers_1.fullCleanCwd)(envFiles?.join(", ") || "")
118
+ .replaceAll(`${process.cwd()}/`, "")
119
+ .replaceAll("/", "")}\n`);
120
+ const cleanup = () => {
121
+ if (restartTimeout)
122
+ clearTimeout(restartTimeout);
123
+ if (envWatcher)
124
+ envWatcher.close();
125
+ if (child) {
126
+ child.kill("SIGTERM");
127
+ setTimeout(() => {
128
+ if (child && !child.killed)
129
+ child.kill("SIGKILL");
130
+ }, 5000);
131
+ }
132
+ process.exit(0);
133
+ };
134
+ process.on("SIGINT", cleanup);
135
+ process.on("SIGTERM", cleanup);
136
+ process.on("uncaughtException", (error) => {
137
+ console.error("Uncaught Exception:", error);
138
+ cleanup();
139
+ });
140
+ }
141
+ catch (error) {
142
+ console.error("Development server failed to start:", error);
143
+ if (child) {
144
+ child?.kill?.();
145
+ child = null;
146
+ }
147
+ process.exit(1);
148
+ }
149
+ }
150
+ function killDevelopmentServerChildProcess() {
151
+ child?.kill?.();
152
+ child = null;
153
+ }
154
+ //# sourceMappingURL=dev.js.map