@joystick.js/node-canary 0.0.0-canary.42 → 0.0.0-canary.420

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 (444) hide show
  1. package/.build/getFilesToBuild.js +26 -0
  2. package/.build/getPlatformSafeFilePath.js +6 -0
  3. package/.build/getPlatformSafePath.js +6 -0
  4. package/.build/index.js +88 -0
  5. package/.build/isWindows.js +3 -0
  6. package/dist/action/class.js +1 -82
  7. package/dist/action/index.js +1 -8
  8. package/dist/app/accounts/default_user_output_fields.js +1 -0
  9. package/dist/app/accounts/delete_user.js +1 -0
  10. package/dist/app/accounts/generate_account_session.js +1 -0
  11. package/dist/app/accounts/generate_password_reset_token.js +1 -0
  12. package/dist/app/accounts/get_browser_safe_user.js +1 -0
  13. package/dist/app/accounts/has_login_token_expired.js +1 -0
  14. package/dist/app/accounts/index.js +1 -29
  15. package/dist/app/accounts/login.js +1 -59
  16. package/dist/app/accounts/recover_password.js +1 -0
  17. package/dist/app/accounts/reset_password.js +1 -0
  18. package/dist/app/accounts/roles/add.js +1 -7
  19. package/dist/app/accounts/roles/grant.js +1 -7
  20. package/dist/app/accounts/roles/index.js +1 -17
  21. package/dist/app/accounts/roles/list.js +1 -7
  22. package/dist/app/accounts/roles/remove.js +1 -7
  23. package/dist/app/accounts/roles/revoke.js +1 -7
  24. package/dist/app/accounts/roles/user_has_role.js +1 -0
  25. package/dist/app/accounts/send_email_verification.js +1 -0
  26. package/dist/app/accounts/set_account_cookie.js +1 -0
  27. package/dist/app/accounts/set_password.js +1 -0
  28. package/dist/app/accounts/signup.js +1 -97
  29. package/dist/app/accounts/unset_account_cookie.js +1 -0
  30. package/dist/app/accounts/verify_email.js +1 -0
  31. package/dist/app/api/accounts/authenticated.js +1 -0
  32. package/dist/app/api/accounts/login.js +1 -0
  33. package/dist/app/api/accounts/logout.js +1 -0
  34. package/dist/app/api/accounts/recover_password.js +1 -0
  35. package/dist/app/api/accounts/reset_password.js +1 -0
  36. package/dist/app/api/accounts/signup.js +1 -0
  37. package/dist/app/api/accounts/user.js +1 -0
  38. package/dist/app/api/accounts/verify_email.js +1 -0
  39. package/dist/app/api/format_api_error.js +1 -0
  40. package/dist/app/api/get.js +2 -0
  41. package/dist/app/api/get_api_context.js +1 -0
  42. package/dist/app/api/get_api_for_data_functions.js +1 -0
  43. package/dist/app/api/get_api_url_component.js +1 -0
  44. package/dist/app/api/get_output.js +1 -0
  45. package/dist/app/api/get_value_from_object.js +1 -0
  46. package/dist/app/api/handle_api_error.js +1 -0
  47. package/dist/app/api/input_validators.js +1 -0
  48. package/dist/app/api/is_array_path.js +1 -0
  49. package/dist/app/api/push/health.js +2 -0
  50. package/dist/app/api/register_getters.js +1 -0
  51. package/dist/app/api/register_setters.js +1 -0
  52. package/dist/app/api/sanitize_api_response.js +1 -0
  53. package/dist/app/api/set.js +2 -0
  54. package/dist/app/api/test/accounts/delete.js +1 -0
  55. package/dist/app/api/test/accounts/signup.js +1 -0
  56. package/dist/app/api/test/bootstrap.js +1 -0
  57. package/dist/app/api/test/process.js +1 -0
  58. package/dist/app/api/test/queues.js +1 -0
  59. package/dist/app/api/validate_input.js +1 -0
  60. package/dist/app/api/validate_session.js +1 -0
  61. package/dist/app/api/validate_type.js +1 -0
  62. package/dist/app/browser/hmr_client.js +1 -0
  63. package/dist/app/browser/process_polyfill.js +1 -0
  64. package/dist/app/cron_jobs/register.js +1 -0
  65. package/dist/app/databases/database_type_map.js +1 -0
  66. package/dist/app/databases/get_target_database_connection.js +1 -0
  67. package/dist/app/databases/mongodb/available_query_parameters.js +1 -0
  68. package/dist/app/databases/mongodb/build_connection_string.js +1 -0
  69. package/dist/app/databases/mongodb/build_query_parameters.js +1 -0
  70. package/dist/app/databases/mongodb/connect.js +6 -0
  71. package/dist/app/databases/mongodb/create_indexes.js +1 -0
  72. package/dist/app/databases/postgresql/accounts/create_accounts_metadata_table_columns.js +1 -0
  73. package/dist/app/databases/postgresql/connect.js +30 -0
  74. package/dist/app/databases/postgresql/create_indexes.js +1 -0
  75. package/dist/app/databases/postgresql/create_tables.js +1 -0
  76. package/dist/app/databases/postgresql/handle_cleanup_queues.js +5 -0
  77. package/dist/app/databases/postgresql/handle_cleanup_sessions.js +1 -0
  78. package/dist/app/databases/queries/accounts.js +1 -0
  79. package/dist/app/databases/queries/map.js +1 -0
  80. package/dist/app/databases/queries/mongodb/accounts.js +1 -0
  81. package/dist/app/databases/queries/mongodb/queues.js +1 -0
  82. package/dist/app/databases/queries/mongodb/sessions.js +1 -0
  83. package/dist/app/databases/queries/postgresql/accounts.js +1 -0
  84. package/dist/app/databases/queries/postgresql/queues.js +123 -0
  85. package/dist/app/databases/queries/postgresql/sessions.js +14 -0
  86. package/dist/app/databases/queries/sessions.js +1 -0
  87. package/dist/app/databases/register_database.js +1 -0
  88. package/dist/app/databases/sql.js +1 -0
  89. package/dist/app/email/send.js +1 -0
  90. package/dist/app/email/validate_smtp_settings.js +1 -0
  91. package/dist/app/fixture/index.js +1 -0
  92. package/dist/app/generate_machine_id.js +1 -0
  93. package/dist/app/generate_process_id.js +1 -0
  94. package/dist/app/get_ssl_certificates.js +1 -0
  95. package/dist/app/handle_process_errors.js +1 -0
  96. package/dist/app/index.js +1 -654
  97. package/dist/app/middleware/account.js +1 -0
  98. package/dist/app/middleware/body_parser.js +1 -0
  99. package/dist/app/middleware/build_error.js +1 -0
  100. package/dist/app/middleware/built_in.js +1 -0
  101. package/dist/app/middleware/context.js +1 -0
  102. package/dist/app/middleware/cors.js +1 -22
  103. package/dist/app/middleware/csp.js +1 -48
  104. package/dist/app/middleware/generate_insecure_page.js +65 -0
  105. package/dist/app/middleware/generate_joystick_error_page.js +147 -0
  106. package/dist/app/middleware/hmr_client.js +1 -0
  107. package/dist/app/middleware/insecure.js +1 -11
  108. package/dist/app/middleware/process_browser_polyfill.js +1 -0
  109. package/dist/app/middleware/render/get_url.js +1 -0
  110. package/dist/app/middleware/render/index.js +1 -0
  111. package/dist/app/middleware/request_methods.js +1 -0
  112. package/dist/app/middleware/session.js +1 -24
  113. package/dist/app/push_logs.js +1 -0
  114. package/dist/app/queues/index.js +1 -119
  115. package/dist/app/register_app_options.js +1 -0
  116. package/dist/app/routes/register_route_from_function.js +1 -0
  117. package/dist/app/routes/register_route_from_object.js +1 -0
  118. package/dist/app/routes/supported_http_methods.js +1 -0
  119. package/dist/app/settings/load.js +1 -0
  120. package/dist/app/ssr/index.js +32 -0
  121. package/dist/app/ssr/set_base_attributes_in_html.js +1 -0
  122. package/dist/app/ssr/set_head_tags_in_html.js +1 -0
  123. package/dist/app/start_express.js +1 -0
  124. package/dist/app/start_node_as_cluster.js +1 -0
  125. package/dist/app/uploaders/local_upload_progress_middleware.js +1 -0
  126. package/dist/app/uploaders/register.js +1 -0
  127. package/dist/app/uploaders/run_upload.js +1 -0
  128. package/dist/app/uploaders/validate_options.js +1 -0
  129. package/dist/app/uploaders/validate_uploads.js +1 -0
  130. package/dist/app/websockets/emit_event.js +1 -0
  131. package/dist/app/websockets/index.js +1 -0
  132. package/dist/app/websockets/register.js +1 -0
  133. package/dist/index.js +4 -76
  134. package/dist/lib/camel_pascal_to_snake.js +1 -0
  135. package/dist/lib/constants.js +1 -13
  136. package/dist/lib/dynamic_import.js +1 -0
  137. package/dist/lib/escape_html.js +1 -0
  138. package/dist/lib/escape_key_value_pair.js +1 -0
  139. package/dist/lib/float_to_decimal_place.js +1 -0
  140. package/dist/lib/generate_id.js +1 -0
  141. package/dist/lib/get_browser_safe_request.js +1 -0
  142. package/dist/lib/get_joystick_build_path.js +1 -0
  143. package/dist/lib/get_origin.js +1 -0
  144. package/dist/lib/get_sanitized_context.js +1 -0
  145. package/dist/lib/get_translations.js +1 -0
  146. package/dist/lib/hash_string.js +1 -0
  147. package/dist/lib/is_valid_json.js +1 -0
  148. package/dist/lib/log.js +13 -52
  149. package/dist/lib/node_path_polyfills.js +1 -0
  150. package/dist/lib/parse_json.js +1 -0
  151. package/dist/lib/path_exists.js +1 -0
  152. package/dist/lib/rainbow_road.js +1 -0
  153. package/dist/lib/replace_backslashes_with_forward_slashes.js +1 -0
  154. package/dist/lib/replace_file_protocol.js +1 -0
  155. package/dist/lib/serialize_query_parameters.js +1 -0
  156. package/dist/lib/set_cookie.js +1 -0
  157. package/dist/lib/string_to_slug.js +1 -0
  158. package/dist/lib/timestamps.js +1 -0
  159. package/dist/lib/types.js +1 -0
  160. package/dist/lib/unset_cookie.js +1 -0
  161. package/dist/lib/wait.js +1 -0
  162. package/dist/test/track_function_call.js +1 -0
  163. package/increment_version.js +3 -0
  164. package/package.json +27 -44
  165. package/src/action/class.js +137 -0
  166. package/src/action/index.js +8 -0
  167. package/src/app/accounts/default_user_output_fields.js +10 -0
  168. package/src/app/accounts/delete_user.js +18 -0
  169. package/src/app/accounts/generate_account_session.js +11 -0
  170. package/src/app/accounts/generate_password_reset_token.js +16 -0
  171. package/src/app/accounts/get_browser_safe_user.js +29 -0
  172. package/src/app/accounts/has_login_token_expired.js +9 -0
  173. package/src/app/accounts/index.js +38 -0
  174. package/src/app/accounts/login.js +82 -0
  175. package/src/app/accounts/recover_password.js +58 -0
  176. package/src/app/accounts/reset_password.js +69 -0
  177. package/src/app/accounts/roles/add.js +7 -0
  178. package/src/app/accounts/roles/grant.js +7 -0
  179. package/src/app/accounts/roles/index.js +18 -0
  180. package/src/app/accounts/roles/list.js +7 -0
  181. package/src/app/accounts/roles/remove.js +7 -0
  182. package/src/app/accounts/roles/revoke.js +7 -0
  183. package/src/app/accounts/roles/user_has_role.js +7 -0
  184. package/src/app/accounts/send_email_verification.js +48 -0
  185. package/src/app/accounts/set_account_cookie.js +12 -0
  186. package/src/app/accounts/set_password.js +46 -0
  187. package/src/app/accounts/signup.js +158 -0
  188. package/src/app/accounts/unset_account_cookie.js +12 -0
  189. package/src/app/accounts/verify_email.js +32 -0
  190. package/src/app/api/accounts/authenticated.js +17 -0
  191. package/src/app/api/accounts/login.js +36 -0
  192. package/src/app/api/accounts/logout.js +20 -0
  193. package/src/app/api/accounts/recover_password.js +16 -0
  194. package/src/app/api/accounts/reset_password.js +24 -0
  195. package/src/app/api/accounts/signup.js +49 -0
  196. package/src/app/api/accounts/user.js +21 -0
  197. package/src/app/api/accounts/verify_email.js +11 -0
  198. package/src/app/api/format_api_error.js +10 -0
  199. package/src/app/api/get.js +119 -0
  200. package/src/app/api/get_api_context.js +27 -0
  201. package/src/app/api/get_api_for_data_functions.js +37 -0
  202. package/src/app/api/get_api_url_component.js +5 -0
  203. package/src/app/api/get_output.js +116 -0
  204. package/src/app/api/get_value_from_object.js +8 -0
  205. package/src/app/api/handle_api_error.js +28 -0
  206. package/src/app/api/input_validators.js +227 -0
  207. package/src/app/api/is_array_path.js +6 -0
  208. package/src/app/api/push/health.js +17 -0
  209. package/src/app/api/register_getters.js +57 -0
  210. package/src/app/api/register_setters.js +55 -0
  211. package/src/app/api/sanitize_api_response.js +35 -0
  212. package/src/app/api/set.js +119 -0
  213. package/src/app/api/test/accounts/delete.js +8 -0
  214. package/src/app/api/test/accounts/signup.js +50 -0
  215. package/src/app/api/test/bootstrap.js +36 -0
  216. package/src/app/api/test/process.js +7 -0
  217. package/src/app/api/test/queues.js +25 -0
  218. package/src/app/api/validate_input.js +132 -0
  219. package/src/app/api/validate_session.js +20 -0
  220. package/src/app/api/validate_type.js +24 -0
  221. package/src/app/browser/hmr_client.js +196 -0
  222. package/src/app/browser/process_polyfill.js +11 -0
  223. package/src/app/cron_jobs/register.js +29 -0
  224. package/src/app/databases/database_type_map.js +6 -0
  225. package/src/app/databases/get_target_database_connection.js +25 -0
  226. package/{dist/app/databases/mongodb/availableQueryParameters.js → src/app/databases/mongodb/available_query_parameters.js} +3 -4
  227. package/src/app/databases/mongodb/build_connection_string.js +30 -0
  228. package/src/app/databases/mongodb/build_query_parameters.js +17 -0
  229. package/src/app/databases/mongodb/connect.js +42 -0
  230. package/src/app/databases/mongodb/create_indexes.js +35 -0
  231. package/src/app/databases/postgresql/accounts/create_accounts_metadata_table_columns.js +18 -0
  232. package/src/app/databases/postgresql/connect.js +128 -0
  233. package/src/app/databases/postgresql/create_indexes.js +58 -0
  234. package/src/app/databases/postgresql/create_tables.js +70 -0
  235. package/src/app/databases/postgresql/handle_cleanup_queues.js +36 -0
  236. package/src/app/databases/postgresql/handle_cleanup_sessions.js +5 -0
  237. package/src/app/databases/queries/accounts.js +17 -0
  238. package/src/app/databases/queries/map.js +21 -0
  239. package/src/app/databases/queries/mongodb/accounts.js +360 -0
  240. package/src/app/databases/queries/mongodb/queues.js +157 -0
  241. package/src/app/databases/queries/mongodb/sessions.js +22 -0
  242. package/src/app/databases/queries/postgresql/accounts.js +379 -0
  243. package/src/app/databases/queries/postgresql/queues.js +288 -0
  244. package/src/app/databases/queries/postgresql/sessions.js +37 -0
  245. package/src/app/databases/queries/sessions.js +17 -0
  246. package/src/app/databases/register_database.js +30 -0
  247. package/src/app/databases/sql.js +63 -0
  248. package/src/app/email/send.js +108 -0
  249. package/src/app/email/validate_smtp_settings.js +53 -0
  250. package/src/app/fixture/index.js +50 -0
  251. package/src/app/generate_machine_id.js +26 -0
  252. package/src/app/generate_process_id.js +30 -0
  253. package/src/app/get_ssl_certificates.js +23 -0
  254. package/src/app/handle_process_errors.js +101 -0
  255. package/src/app/index.js +248 -0
  256. package/src/app/middleware/account.js +28 -0
  257. package/src/app/middleware/body_parser.js +18 -0
  258. package/src/app/middleware/build_error.js +18 -0
  259. package/src/app/middleware/built_in.js +76 -0
  260. package/src/app/middleware/context.js +34 -0
  261. package/src/app/middleware/cors.js +23 -0
  262. package/src/app/middleware/csp.js +54 -0
  263. package/src/app/middleware/generate_insecure_page.js +71 -0
  264. package/{dist/lib/generateErrorPage.js → src/app/middleware/generate_joystick_error_page.js} +25 -21
  265. package/src/app/middleware/hmr_client.js +12 -0
  266. package/src/app/middleware/insecure.js +22 -0
  267. package/src/app/middleware/process_browser_polyfill.js +12 -0
  268. package/src/app/middleware/render/get_url.js +15 -0
  269. package/src/app/middleware/render/index.js +93 -0
  270. package/src/app/middleware/request_methods.js +21 -0
  271. package/src/app/middleware/session.js +31 -0
  272. package/src/app/push_logs.js +36 -0
  273. package/src/app/queues/index.js +268 -0
  274. package/src/app/register_app_options.js +7 -0
  275. package/src/app/routes/register_route_from_function.js +10 -0
  276. package/src/app/routes/register_route_from_object.js +34 -0
  277. package/src/app/routes/supported_http_methods.js +9 -0
  278. package/src/app/settings/load.js +33 -0
  279. package/src/app/ssr/index.js +131 -0
  280. package/src/app/ssr/set_base_attributes_in_html.js +43 -0
  281. package/src/app/ssr/set_head_tags_in_html.js +104 -0
  282. package/src/app/start_express.js +50 -0
  283. package/src/app/start_node_as_cluster.js +30 -0
  284. package/src/app/uploaders/local_upload_progress_middleware.js +24 -0
  285. package/src/app/uploaders/register.js +169 -0
  286. package/src/app/uploaders/run_upload.js +136 -0
  287. package/src/app/uploaders/validate_options.js +74 -0
  288. package/src/app/uploaders/validate_uploads.js +127 -0
  289. package/src/app/websockets/emit_event.js +14 -0
  290. package/src/app/websockets/index.js +16 -0
  291. package/src/app/websockets/register.js +175 -0
  292. package/src/index.js +82 -0
  293. package/{dist/lib/camelPascalToSnake.js → src/lib/camel_pascal_to_snake.js} +3 -4
  294. package/src/lib/constants.js +21 -0
  295. package/src/lib/dynamic_import.js +6 -0
  296. package/src/lib/escape_html.js +9 -0
  297. package/src/lib/escape_key_value_pair.js +15 -0
  298. package/src/lib/float_to_decimal_place.js +5 -0
  299. package/src/lib/generate_id.js +15 -0
  300. package/src/lib/get_browser_safe_request.js +17 -0
  301. package/src/lib/get_joystick_build_path.js +28 -0
  302. package/src/lib/get_origin.js +7 -0
  303. package/src/lib/get_sanitized_context.js +51 -0
  304. package/src/lib/get_translations.js +102 -0
  305. package/src/lib/hash_string.js +7 -0
  306. package/src/lib/is_valid_json.js +10 -0
  307. package/src/lib/log.js +42 -0
  308. package/src/lib/node_path_polyfills.js +18 -0
  309. package/src/lib/parse_json.js +9 -0
  310. package/src/lib/path_exists.js +11 -0
  311. package/src/lib/rainbow_road.js +7 -0
  312. package/src/lib/replace_backslashes_with_forward_slashes.js +8 -0
  313. package/src/lib/replace_file_protocol.js +8 -0
  314. package/src/lib/serialize_query_parameters.js +7 -0
  315. package/src/lib/set_cookie.js +16 -0
  316. package/src/lib/string_to_slug.js +14 -0
  317. package/src/lib/timestamps.js +48 -0
  318. package/src/lib/types.js +59 -0
  319. package/src/lib/unset_cookie.js +11 -0
  320. package/src/lib/wait.js +9 -0
  321. package/src/test/track_function_call.js +16 -0
  322. package/README.md +0 -8
  323. package/_package.json +0 -63
  324. package/canary.js +0 -12
  325. package/dist/api/get.js +0 -29
  326. package/dist/api/getOrigin.js +0 -6
  327. package/dist/api/index.js +0 -9
  328. package/dist/api/set.js +0 -29
  329. package/dist/app/accounts/defaultUserOutputFields.js +0 -9
  330. package/dist/app/accounts/generateResetToken.js +0 -28
  331. package/dist/app/accounts/generateSession.js +0 -15
  332. package/dist/app/accounts/getBrowserSafeUser.js +0 -24
  333. package/dist/app/accounts/hasLoginTokenExpired.js +0 -18
  334. package/dist/app/accounts/hashString.js +0 -7
  335. package/dist/app/accounts/recoverPassword.js +0 -30
  336. package/dist/app/accounts/resetPassword.js +0 -73
  337. package/dist/app/accounts/roles/index.test.js +0 -123
  338. package/dist/app/accounts/roles/userHasRole.js +0 -7
  339. package/dist/app/accounts/runUserQuery.js +0 -15
  340. package/dist/app/accounts/sendEmailVerification.js +0 -65
  341. package/dist/app/accounts/setAuthenticationCookie.js +0 -11
  342. package/dist/app/accounts/setPassword.js +0 -45
  343. package/dist/app/accounts/unsetAuthenticationCookie.js +0 -11
  344. package/dist/app/accounts/verifyEmail.js +0 -46
  345. package/dist/app/databases/getTargetDatabase.js +0 -10
  346. package/dist/app/databases/getTargetDatabaseConnection.js +0 -19
  347. package/dist/app/databases/getTargetDatabaseProvider.js +0 -10
  348. package/dist/app/databases/mongodb/buildConnectionString.js +0 -22
  349. package/dist/app/databases/mongodb/buildQueryParameters.js +0 -14
  350. package/dist/app/databases/mongodb/index.js +0 -40
  351. package/dist/app/databases/mongodb/queries/accounts.js +0 -266
  352. package/dist/app/databases/mongodb/queries/queues.js +0 -111
  353. package/dist/app/databases/postgresql/addColumnToTable.js +0 -6
  354. package/dist/app/databases/postgresql/createAccountsIndexes.js +0 -21
  355. package/dist/app/databases/postgresql/createAccountsTables.js +0 -39
  356. package/dist/app/databases/postgresql/createDatabase.js +0 -0
  357. package/dist/app/databases/postgresql/index.js +0 -55
  358. package/dist/app/databases/postgresql/queries/accounts.js +0 -186
  359. package/dist/app/databases/postgresql/queries/queues.js +0 -211
  360. package/dist/app/databases/queryMap.js +0 -17
  361. package/dist/app/databases/typesMap.js +0 -7
  362. package/dist/app/getAPIContext.js +0 -25
  363. package/dist/app/getAPIURLComponent.js +0 -6
  364. package/dist/app/getBrowserSafeRequest.js +0 -14
  365. package/dist/app/getOutput.js +0 -74
  366. package/dist/app/handleProcessErrors.js +0 -73
  367. package/dist/app/index.test.js +0 -575
  368. package/dist/app/initExpress.js +0 -41
  369. package/dist/app/middleware/bodyParser.js +0 -16
  370. package/dist/app/middleware/hmr/client.js +0 -113
  371. package/dist/app/middleware/index.js +0 -89
  372. package/dist/app/middleware/render.js +0 -213
  373. package/dist/app/middleware/requestMethods.js +0 -19
  374. package/dist/app/registerGetters.js +0 -45
  375. package/dist/app/registerSetters.js +0 -45
  376. package/dist/app/runGetter.js +0 -103
  377. package/dist/app/runSetter.js +0 -103
  378. package/dist/app/runUploader.js +0 -143
  379. package/dist/app/sanitizeAPIResponse.js +0 -27
  380. package/dist/app/utils/process.js +0 -193
  381. package/dist/app/validateSession.js +0 -16
  382. package/dist/app/validateUploaderOptions.js +0 -53
  383. package/dist/app/validateUploads.js +0 -102
  384. package/dist/email/render.js +0 -50
  385. package/dist/email/send.js +0 -55
  386. package/dist/email/send.test.js +0 -37
  387. package/dist/email/templates/base.css +0 -194
  388. package/dist/email/templates/base.html +0 -28
  389. package/dist/email/templates/reset-password.js +0 -14
  390. package/dist/email/validateSMTPSettings.js +0 -27
  391. package/dist/lib/escapeHTML.js +0 -9
  392. package/dist/lib/escapeKeyValuePair.js +0 -13
  393. package/dist/lib/formatAPIError.js +0 -12
  394. package/dist/lib/formatErrorString.js +0 -8
  395. package/dist/lib/generateCookie.js +0 -14
  396. package/dist/lib/generateId.js +0 -13
  397. package/dist/lib/generateMachineId.js +0 -15
  398. package/dist/lib/getBuildPath.js +0 -10
  399. package/dist/lib/getErrorObject.js +0 -9
  400. package/dist/lib/getPlatformSafeFilePath.js +0 -8
  401. package/dist/lib/getPlatformSafePath.js +0 -8
  402. package/dist/lib/getSSLCertificates.js +0 -19
  403. package/dist/lib/isValidHTTPMethod.js +0 -7
  404. package/dist/lib/isValidJSONString.js +0 -11
  405. package/dist/lib/nodeUrlPolyfills.js +0 -14
  406. package/dist/lib/objectToSQLKeysString.js +0 -18
  407. package/dist/lib/objectToSQLValuesString.js +0 -16
  408. package/dist/lib/obscenedb/debounce.js +0 -12
  409. package/dist/lib/obscenedb/index.js +0 -61
  410. package/dist/lib/parseDatabasesFromEnvironment.js +0 -9
  411. package/dist/lib/rainbowRoad.js +0 -7
  412. package/dist/lib/readDirectory.js +0 -24
  413. package/dist/lib/replaceBackslashesWithForwardSlashes.js +0 -8
  414. package/dist/lib/replaceFileProtocol.js +0 -8
  415. package/dist/lib/replaceForwardSlashesWithBackslashes.js +0 -8
  416. package/dist/lib/serializeQueryParameters.js +0 -8
  417. package/dist/lib/serverAvailable.js +0 -0
  418. package/dist/lib/setCookie.js +0 -16
  419. package/dist/lib/supportedHTTPMethods.js +0 -4
  420. package/dist/lib/unsetCookie.js +0 -13
  421. package/dist/push/logs/index.js +0 -55
  422. package/dist/settings/index.js +0 -5
  423. package/dist/settings/load.js +0 -30
  424. package/dist/ssr/compileCSS.js +0 -85
  425. package/dist/ssr/findComponentInTree.js +0 -29
  426. package/dist/ssr/formatCSS.js +0 -6
  427. package/dist/ssr/getCSSFromTree.js +0 -33
  428. package/dist/ssr/index.js +0 -441
  429. package/dist/ssr/replaceWhenTags.js +0 -37
  430. package/dist/ssr/setHeadTagsInHTML.js +0 -84
  431. package/dist/validation/index.js +0 -10
  432. package/dist/validation/index.test.js +0 -463
  433. package/dist/validation/inputWithSchema/index.js +0 -105
  434. package/dist/validation/lib/constants.js +0 -162
  435. package/dist/validation/lib/getValueFromObject.js +0 -12
  436. package/dist/validation/lib/getValueFromObject.test.js +0 -7
  437. package/dist/validation/lib/isArrayPath.js +0 -6
  438. package/dist/validation/lib/throwError.js +0 -6
  439. package/dist/validation/lib/typeValidators.js +0 -38
  440. package/dist/validation/lib/validateType.js +0 -33
  441. package/dist/validation/schema/index.js +0 -44
  442. package/dist/websockets/emitWebsocketEvent.js +0 -12
  443. package/dist/websockets/index.js +0 -12
  444. package/notes +0 -1
@@ -1,575 +0,0 @@
1
- import { afterAll, afterEach, beforeAll, expect, jest, test } from "@jest/globals";
2
- import { mockRequest, mockResponse } from "jest-mock-req-res";
3
- import { killPortProcess } from "kill-port-process";
4
- import assertRoutesDoNotExistInRegexes from "../tests/lib/assertRoutesDoNotExistInRegexes";
5
- import assertRoutesExistInRegexes from "../tests/lib/assertRoutesExistInRegexes";
6
- import setAppSettingsForTest from "../tests/lib/setAppSettingsForTest";
7
- import startTestDatabase from "../tests/lib/databases/start";
8
- import stopTestDatabase from "../tests/lib/databases/stop";
9
- import getRouteRegexes from "../tests/lib/getRouteRegexes";
10
- jest.mock("../../node_modules/crypto-extra", () => {
11
- return {
12
- randomString: () => "abc1234"
13
- };
14
- });
15
- jest.mock("../../node_modules/bcrypt", () => {
16
- return {
17
- hashSync: () => "hashed$password",
18
- compareSync: () => {
19
- return true;
20
- }
21
- };
22
- });
23
- jest.mock("../../node_modules/dayjs", () => {
24
- const _dayjs = jest.requireActual("../../node_modules/dayjs");
25
- const _utc = jest.requireActual("../../node_modules/dayjs/plugin/utc");
26
- _dayjs.extend(_utc);
27
- return () => _dayjs("2022-01-01T00:00:00.000Z");
28
- });
29
- const nodemailer = {
30
- smtp: {
31
- sendMail: jest.fn()
32
- }
33
- };
34
- jest.mock("../../node_modules/nodemailer", () => {
35
- return {
36
- createTransport: jest.fn(() => {
37
- return {
38
- sendMail: nodemailer.smtp.sendMail
39
- };
40
- })
41
- };
42
- });
43
- jest.mock("../../node_modules/@joystick.js/ui/dist/component/generateId.js", () => {
44
- return "component1234";
45
- });
46
- setAppSettingsForTest({
47
- "config": {
48
- "databases": [
49
- {
50
- "provider": "mongodb",
51
- "users": true,
52
- "options": {}
53
- }
54
- ],
55
- "i18n": {
56
- "defaultLanguage": "en-US"
57
- },
58
- "middleware": {},
59
- "email": {
60
- "from": "app@test.com",
61
- "smtp": {
62
- "host": "fake.email.com",
63
- "port": 587,
64
- "username": "test",
65
- "password": "password"
66
- }
67
- }
68
- },
69
- "global": {},
70
- "public": {},
71
- "private": {}
72
- });
73
- const dayjs = (await import("dayjs")).default;
74
- const app = (await import("./index")).default;
75
- const generateId = (await import("../lib/generateId")).default;
76
- global.joystick = {
77
- settings: {
78
- config: {
79
- databases: [{
80
- "provider": "mongodb",
81
- "users": true,
82
- "options": {}
83
- }]
84
- }
85
- }
86
- };
87
- describe("index.js", () => {
88
- beforeAll(async () => {
89
- process.env.PORT = 3600;
90
- await startTestDatabase("mongodb");
91
- });
92
- afterEach(async () => {
93
- await killPortProcess(process.env.PORT);
94
- });
95
- afterAll(async () => {
96
- await stopTestDatabase();
97
- });
98
- test("registers render-related routes", async () => {
99
- const instance = await app({});
100
- if (instance?.server?.close && typeof instance.server.close === "function") {
101
- instance.server.close();
102
- }
103
- if (instance?.app?._router) {
104
- const routeRegexes = getRouteRegexes(instance.app._router.stack);
105
- assertRoutesExistInRegexes(routeRegexes, [
106
- "/_joystick/heartbeat",
107
- "/_joystick/utils/process.js",
108
- "/_joystick/index.client.js",
109
- "/_joystick/index.css",
110
- "/_joystick/ui",
111
- "/_joystick/hmr/client.js"
112
- ]);
113
- }
114
- });
115
- test("registers accounts-related routes", async () => {
116
- const instance = await app({});
117
- if (instance?.server?.close && typeof instance.server.close === "function") {
118
- instance.server.close();
119
- }
120
- if (instance?.app?._router) {
121
- const routeRegexes = getRouteRegexes(instance.app._router.stack);
122
- assertRoutesExistInRegexes(routeRegexes, [
123
- "/api/_accounts/login",
124
- "/api/_accounts/logout",
125
- "/api/_accounts/signup",
126
- "/api/_accounts/recover-password",
127
- "/api/_accounts/reset-password"
128
- ]);
129
- }
130
- });
131
- test("registers getter routes", async () => {
132
- const instance = await app({
133
- api: {
134
- getters: {
135
- posts: {
136
- input: {},
137
- get: () => {
138
- }
139
- },
140
- post: {
141
- input: {},
142
- get: () => {
143
- }
144
- }
145
- }
146
- }
147
- });
148
- if (instance?.server?.close && typeof instance.server.close === "function") {
149
- instance.server.close();
150
- }
151
- if (instance?.app?._router) {
152
- const routeRegexes = getRouteRegexes(instance.app._router.stack);
153
- assertRoutesExistInRegexes(routeRegexes, [
154
- "/api/_getters/posts",
155
- "/api/_getters/post"
156
- ]);
157
- }
158
- });
159
- test("registers setter routes", async () => {
160
- const instance = await app({
161
- api: {
162
- setters: {
163
- createPost: {
164
- input: {},
165
- set: () => {
166
- }
167
- },
168
- updatePost: {
169
- input: {},
170
- set: () => {
171
- }
172
- }
173
- }
174
- }
175
- });
176
- if (instance?.server?.close && typeof instance.server.close === "function") {
177
- instance.server.close();
178
- }
179
- if (instance?.app?._router) {
180
- const routeRegexes = getRouteRegexes(instance.app._router.stack);
181
- assertRoutesExistInRegexes(routeRegexes, [
182
- "/api/_setters/createPost",
183
- "/api/_setters/updatePost"
184
- ]);
185
- }
186
- });
187
- test("registers custom routes if passed as function", async () => {
188
- const instance = await app({
189
- routes: {
190
- "/latest": () => {
191
- },
192
- "/profile/:_id": () => {
193
- },
194
- "/category/:category/posts": () => {
195
- }
196
- }
197
- });
198
- if (instance?.app?._router) {
199
- const routeRegexes = getRouteRegexes(instance.app._router.stack);
200
- assertRoutesExistInRegexes(routeRegexes, [
201
- "/latest",
202
- "/profile/123",
203
- "/category/tutorials/posts"
204
- ]);
205
- }
206
- if (instance?.server?.close && typeof instance.server.close === "function") {
207
- instance.server.close();
208
- }
209
- });
210
- test("does not register custom routes if passed as function not set to a function", async () => {
211
- const instance = await app({
212
- routes: {
213
- "/latest": "function",
214
- "/profile/:_id": "function",
215
- "/category/:category/posts": "function"
216
- }
217
- });
218
- if (instance?.app?._router) {
219
- const routeRegexes = getRouteRegexes(instance.app._router.stack);
220
- assertRoutesDoNotExistInRegexes(routeRegexes, [
221
- "/latest",
222
- "/profile/123",
223
- "/category/tutorials/posts"
224
- ]);
225
- }
226
- if (instance?.server?.close && typeof instance.server.close === "function") {
227
- instance.server.close();
228
- }
229
- });
230
- test("registers custom routes if passed as an object", async () => {
231
- const instance = await app({
232
- routes: {
233
- "/latest": {
234
- method: "GET",
235
- handler: () => {
236
- }
237
- },
238
- "/profile/:_id": {
239
- method: "POST",
240
- handler: () => {
241
- }
242
- },
243
- "/category/:category/posts": {
244
- method: "PUT",
245
- handler: () => {
246
- }
247
- }
248
- }
249
- });
250
- if (instance?.server?.close && typeof instance.server.close === "function") {
251
- instance.server.close();
252
- }
253
- if (instance?.app?._router) {
254
- const routeRegexes = getRouteRegexes(instance.app._router.stack);
255
- assertRoutesExistInRegexes(routeRegexes, [
256
- "/latest",
257
- "/profile/123",
258
- "/category/tutorials/posts"
259
- ]);
260
- }
261
- });
262
- test("does not register custom routes if passed as an object without a valid method", async () => {
263
- const instance = await app({
264
- routes: {
265
- "/latest": {
266
- method: "CAT"
267
- },
268
- "/profile/:_id": {
269
- handler: () => {
270
- }
271
- },
272
- "/category/:category/posts": {
273
- method: "PUT",
274
- handler: () => {
275
- }
276
- }
277
- }
278
- });
279
- if (instance?.server?.close && typeof instance.server.close === "function") {
280
- instance.server.close();
281
- }
282
- if (instance?.app?._router) {
283
- const routeRegexes = getRouteRegexes(instance.app._router.stack);
284
- assertRoutesDoNotExistInRegexes(routeRegexes, [
285
- "/latest",
286
- "/profile/123"
287
- ]);
288
- assertRoutesExistInRegexes(routeRegexes, [
289
- "/category/tutorials/posts"
290
- ]);
291
- }
292
- });
293
- test("does not register custom routes if passed as an object without a handler function", async () => {
294
- const instance = await app({
295
- routes: {
296
- "/latest": {
297
- method: "GET"
298
- },
299
- "/profile/:_id": {
300
- method: "POST"
301
- },
302
- "/category/:category/posts": {
303
- method: "PUT"
304
- }
305
- }
306
- });
307
- if (instance?.server?.close && typeof instance.server.close === "function") {
308
- instance.server.close();
309
- }
310
- if (instance?.app?._router) {
311
- const routeRegexes = getRouteRegexes(instance.app._router.stack);
312
- assertRoutesDoNotExistInRegexes(routeRegexes, [
313
- "/latest",
314
- "/profile/123",
315
- "/category/tutorials/posts"
316
- ]);
317
- }
318
- });
319
- test("sets build errors on process", async () => {
320
- const instance = await app({});
321
- const testMessage = { id: generateId() };
322
- process.emit("message", JSON.stringify(testMessage));
323
- if (instance?.server?.close && typeof instance.server.close === "function") {
324
- instance.server.close();
325
- }
326
- expect(process.BUILD_ERROR).toEqual(testMessage);
327
- });
328
- test("if callback function is assigned to function-based route, it is called as expected", async () => {
329
- const instance = await app({
330
- routes: {
331
- "/test": (req2, res2) => {
332
- res2.status(200).send("Called as expected.");
333
- }
334
- }
335
- });
336
- const route = instance?.app?._router?.stack.find((stackItem) => {
337
- return stackItem?.route?.path === "/test";
338
- });
339
- if (instance?.server?.close && typeof instance.server.close === "function") {
340
- instance.server.close();
341
- }
342
- const req = mockRequest();
343
- const res = mockResponse();
344
- const handler = route?.route?.stack[0] && route?.route?.stack[0].handle;
345
- if (handler) {
346
- await handler(req, res, () => {
347
- });
348
- expect(res.status).toHaveBeenCalledWith(200);
349
- expect(res.send).toHaveBeenCalledWith("Called as expected.");
350
- }
351
- });
352
- test("if callback function is assigned to an object-based route, it is called as expected", async () => {
353
- const instance = await app({
354
- routes: {
355
- "/test": {
356
- method: "GET",
357
- handler: (req2, res2) => {
358
- res2.status(200).send("Called as expected.");
359
- }
360
- }
361
- }
362
- });
363
- const route = instance?.app?._router?.stack.find((stackItem) => {
364
- return stackItem?.route?.path === "/test";
365
- });
366
- if (instance?.server?.close && typeof instance.server.close === "function") {
367
- instance.server.close();
368
- }
369
- const req = mockRequest();
370
- const res = mockResponse();
371
- const handler = route?.route?.stack[0] && route?.route?.stack[0].handle;
372
- if (handler) {
373
- await handler(req, res, () => {
374
- });
375
- expect(res.status).toHaveBeenCalledWith(200);
376
- expect(res.send).toHaveBeenCalledWith("Called as expected.");
377
- }
378
- });
379
- test("verify that a /_accounts/authenticated request will return true if passed a valid cookie", async () => {
380
- const instance = await app({});
381
- const route = instance?.app?._router?.stack.find((stackItem) => {
382
- return stackItem?.route?.path === "/api/_accounts/authenticated";
383
- });
384
- const req = mockRequest({
385
- cookies: {
386
- joystickLoginToken: "testToken123",
387
- joystickLoginTokenExpiresAt: dayjs().add(1, "minute").format()
388
- }
389
- });
390
- const res = mockResponse();
391
- const handler = route?.route?.stack[0] && route?.route?.stack[0].handle;
392
- if (handler) {
393
- await handler(req, res, () => {
394
- });
395
- expect(res.status).toHaveBeenCalledWith(200);
396
- expect(res.send).toHaveBeenCalledWith('{"status":200,"authenticated":true}');
397
- }
398
- if (instance?.server?.close && typeof instance.server.close === "function") {
399
- instance.server.close();
400
- }
401
- });
402
- test("verify that a /_accounts/authenticated request will return false if passed an invalid cookie", async () => {
403
- const instance = await app({});
404
- const route = instance?.app?._router?.stack.find((stackItem) => {
405
- return stackItem?.route?.path === "/api/_accounts/authenticated";
406
- });
407
- if (instance?.server?.close && typeof instance.server.close === "function") {
408
- instance.server.close();
409
- }
410
- const req = mockRequest({
411
- cookies: {
412
- joystickLoginToken: "testToken123",
413
- joystickLoginTokenExpiresAt: jest.requireActual("../../node_modules/dayjs")().subtract(1, "minute").format()
414
- }
415
- });
416
- const res = mockResponse();
417
- const handler = route?.route?.stack[0] && route?.route?.stack[0].handle;
418
- if (handler) {
419
- await handler(req, res, () => {
420
- });
421
- expect(res.status).toHaveBeenCalledWith(401);
422
- expect(res.send).toHaveBeenCalledWith('{"status":401,"authenticated":false}');
423
- }
424
- });
425
- test("verify that a /_accounts/signup request will set a cookie and return a user if passed a valid signup request", async () => {
426
- const instance = await app({});
427
- const route = instance?.app?._router?.stack.find((stackItem) => {
428
- return stackItem?.route?.path === "/api/_accounts/signup";
429
- });
430
- if (instance?.server?.close && typeof instance.server.close === "function") {
431
- instance.server.close();
432
- }
433
- const req = mockRequest({
434
- body: {
435
- emailAddress: "test@test.com",
436
- password: "password",
437
- metadata: {}
438
- }
439
- });
440
- const res = mockResponse();
441
- const handler = route?.route?.stack[0] && route?.route?.stack[0].handle;
442
- if (handler) {
443
- await handler(req, res, () => {
444
- });
445
- expect(res.cookie).toHaveBeenCalledWith("joystickLoginToken", "abc1234", { secure: true, httpOnly: true, expires: dayjs().toDate() });
446
- expect(res.cookie).toHaveBeenCalledWith("joystickLoginTokenExpiresAt", "2022-01-31T00:00:00Z", { secure: true, httpOnly: true, expires: dayjs().toDate() });
447
- expect(res.status).toHaveBeenCalledWith(200);
448
- expect(res.send).toHaveBeenCalledWith('{"_id":"abc1234","password":"hashed$password","emailAddress":"test@test.com"}');
449
- }
450
- });
451
- test("verify that a /_accounts/login request will set a cookie and return a user if passed a valid login request", async () => {
452
- const instance = await app({});
453
- const route = instance?.app?._router?.stack.find((stackItem) => {
454
- return stackItem?.route?.path === "/api/_accounts/login";
455
- });
456
- if (instance?.server?.close && typeof instance.server.close === "function") {
457
- instance.server.close();
458
- }
459
- const req = mockRequest({
460
- body: {
461
- emailAddress: "test@test.com",
462
- password: "password"
463
- }
464
- });
465
- const res = mockResponse();
466
- const handler = route?.route?.stack[0] && route?.route?.stack[0].handle;
467
- if (handler) {
468
- await handler(req, res, () => {
469
- });
470
- expect(res.cookie).toHaveBeenCalledWith("joystickLoginToken", "abc1234", { secure: true, httpOnly: true, expires: dayjs().toDate() });
471
- expect(res.cookie).toHaveBeenCalledWith("joystickLoginTokenExpiresAt", "2022-01-31T00:00:00Z", { secure: true, httpOnly: true, expires: dayjs().toDate() });
472
- expect(res.status).toHaveBeenCalledWith(200);
473
- expect(res.send).toHaveBeenCalledWith('{"_id":"abc1234","emailAddress":"test@test.com"}');
474
- }
475
- });
476
- test("verify that a /_accounts/logout request deletes the cookie", async () => {
477
- const instance = await app({});
478
- const loginRoute = instance?.app?._router?.stack.find((stackItem) => {
479
- return stackItem?.route?.path === "/api/_accounts/login";
480
- });
481
- const logoutRoute = instance?.app?._router?.stack.find((stackItem) => {
482
- return stackItem?.route?.path === "/api/_accounts/logout";
483
- });
484
- if (instance?.server?.close && typeof instance.server.close === "function") {
485
- instance.server.close();
486
- }
487
- const loginRequest = mockRequest({
488
- body: {
489
- emailAddress: "test@test.com",
490
- password: "password"
491
- }
492
- });
493
- const loginResponse = mockResponse();
494
- const loginHandler = loginRoute?.route?.stack[0] && loginRoute?.route?.stack[0].handle;
495
- const logoutRequest = mockRequest();
496
- const logoutResponse = mockResponse();
497
- const logoutHandler = logoutRoute?.route?.stack[0] && logoutRoute?.route?.stack[0].handle;
498
- if (loginHandler && logoutHandler) {
499
- await loginHandler(loginRequest, loginResponse, () => {
500
- });
501
- await logoutHandler(logoutRequest, logoutResponse, () => {
502
- });
503
- expect(loginResponse.cookie).toHaveBeenCalledWith("joystickLoginToken", "abc1234", { secure: true, httpOnly: true, expires: dayjs().toDate() });
504
- expect(loginResponse.cookie).toHaveBeenCalledWith("joystickLoginTokenExpiresAt", "2022-01-31T00:00:00Z", { secure: true, httpOnly: true, expires: dayjs().toDate() });
505
- expect(logoutResponse.cookie).toHaveBeenCalledWith("joystickLoginToken", null, { secure: true, httpOnly: true, expires: dayjs().toDate() });
506
- expect(logoutResponse.cookie).toHaveBeenCalledWith("joystickLoginTokenExpiresAt", null, { secure: true, httpOnly: true, expires: dayjs().toDate() });
507
- }
508
- });
509
- test("verify that a /_accounts/recover-password request attempts to send an email", async () => {
510
- const instance = await app({});
511
- const route = instance?.app?._router?.stack.find((stackItem) => {
512
- return stackItem?.route?.path === "/api/_accounts/recover-password";
513
- });
514
- if (instance?.server?.close && typeof instance.server.close === "function") {
515
- instance.server.close();
516
- }
517
- const req = mockRequest({
518
- body: {
519
- emailAddress: "test@test.com"
520
- }
521
- });
522
- const res = mockResponse();
523
- const handler = route?.route?.stack[0] && route?.route?.stack[0].handle;
524
- if (handler) {
525
- await handler(req, res, () => {
526
- });
527
- expect(nodemailer.smtp.sendMail).toHaveBeenCalledWith({
528
- from: "app@test.com",
529
- to: "test@test.com",
530
- subject: "Reset Your Password",
531
- html: `<!doctype html>
532
- <html class="no-js" lang="en">
533
- <head>
534
- <meta charset="utf-8">
535
- <title>Joystick</title>
536
-
537
- </head>
538
- <body style="color: #000; font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif; font-size: 16px; line-height: 24px;">
539
- <div id="email"><div js-c="testComponent1234">
540
- <p>A password reset was requested for this email address (test@test.com). If you requested this reset, click the link below to reset your password:</p>
541
- <p><a href="http://localhost:3600/reset-password/abc1234">Reset Password</a></p>
542
- </div></div>
543
- </body>
544
- </html>
545
- `,
546
- text: "A password reset was requested for this email address (test@test.com). If you\nrequested this reset, click the link below to reset your password:\n\nReset Password [http://localhost:3600/reset-password/abc1234]"
547
- });
548
- }
549
- });
550
- test("verify that a /_accounts/reset-password request sets a cookie and returns the user", async () => {
551
- const instance = await app({});
552
- const route = instance?.app?._router?.stack.find((stackItem) => {
553
- return stackItem?.route?.path === "/api/_accounts/reset-password";
554
- });
555
- if (instance?.server?.close && typeof instance.server.close === "function") {
556
- instance.server.close();
557
- }
558
- const req = mockRequest({
559
- body: {
560
- token: "abc1234",
561
- password: "test@test.com"
562
- }
563
- });
564
- const res = mockResponse();
565
- const handler = route?.route?.stack[0] && route?.route?.stack[0].handle;
566
- if (handler) {
567
- await handler(req, res, () => {
568
- });
569
- expect(res.cookie).toHaveBeenCalledWith("joystickLoginToken", "abc1234", { secure: true, httpOnly: true, expires: dayjs().toDate() });
570
- expect(res.cookie).toHaveBeenCalledWith("joystickLoginTokenExpiresAt", "2022-01-31T00:00:00Z", { secure: true, httpOnly: true, expires: dayjs().toDate() });
571
- expect(res.status).toHaveBeenCalledWith(200);
572
- expect(res.send).toHaveBeenCalledWith('{"_id":"abc1234","password":"hashed$password","emailAddress":"test@test.com","sessions":[{"token":"abc1234","tokenExpiresAt":"2022-01-31T00:00:00Z"}],"passwordResetTokens":[]}');
573
- }
574
- });
575
- });
@@ -1,41 +0,0 @@
1
- import express from "express";
2
- import https from "https";
3
- import middleware from "./middleware/index.js";
4
- import getSSLCertificates from "../lib/getSSLCertificates.js";
5
- var initExpress_default = (onInit = () => {
6
- }, options = {}, appInstance = {}) => {
7
- try {
8
- const ssl = getSSLCertificates(options?.ssl);
9
- const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 2600;
10
- process.env.PORT = port;
11
- const app = express();
12
- const server = ssl ? https.createServer(ssl, app).listen(port) : app.listen(port);
13
- const config = joystick?.settings?.config || {};
14
- middleware({
15
- app,
16
- port,
17
- middlewareConfig: config?.middleware,
18
- appInstance,
19
- cspConfig: options?.csp
20
- });
21
- if (options?.middleware && options?.middleware instanceof Array) {
22
- options.middleware.forEach((middleware2) => {
23
- app.use(middleware2);
24
- });
25
- }
26
- const instance = {
27
- port,
28
- app,
29
- server
30
- };
31
- if (onInit) {
32
- onInit(instance);
33
- }
34
- return instance;
35
- } catch (exception) {
36
- console.warn(exception);
37
- }
38
- };
39
- export {
40
- initExpress_default as default
41
- };
@@ -1,16 +0,0 @@
1
- import express from "express";
2
- var bodyParser_default = (config = {}) => {
3
- return (req, res, next) => {
4
- const contentType = req.headers["content-type"];
5
- if (contentType && contentType === "application/x-www-form-urlencoded") {
6
- return express.urlencoded({
7
- extended: true,
8
- ...config?.urlencoded || {}
9
- })(req, res, next);
10
- }
11
- return express.json(config?.json)(req, res, next);
12
- };
13
- };
14
- export {
15
- bodyParser_default as default
16
- };