@joystick.js/node-canary 0.0.0-canary.47 → 0.0.0-canary.471
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.
- package/.build/getFilesToBuild.js +26 -0
- package/.build/getPlatformSafeFilePath.js +6 -0
- package/.build/getPlatformSafePath.js +6 -0
- package/.build/index.js +88 -0
- package/.build/isWindows.js +3 -0
- package/dist/action/class.js +1 -82
- package/dist/action/index.js +1 -8
- package/dist/app/accounts/default_user_output_fields.js +1 -0
- package/dist/app/accounts/delete_user.js +1 -0
- package/dist/app/accounts/generate_account_session.js +1 -0
- package/dist/app/accounts/generate_password_reset_token.js +1 -0
- package/dist/app/accounts/get_browser_safe_user.js +1 -0
- package/dist/app/accounts/has_login_token_expired.js +1 -0
- package/dist/app/accounts/index.js +1 -29
- package/dist/app/accounts/login.js +1 -59
- package/dist/app/accounts/recover_password.js +1 -0
- package/dist/app/accounts/reset_password.js +1 -0
- package/dist/app/accounts/roles/add.js +1 -7
- package/dist/app/accounts/roles/grant.js +1 -7
- package/dist/app/accounts/roles/index.js +1 -17
- package/dist/app/accounts/roles/list.js +1 -7
- package/dist/app/accounts/roles/remove.js +1 -7
- package/dist/app/accounts/roles/revoke.js +1 -7
- package/dist/app/accounts/roles/user_has_role.js +1 -0
- package/dist/app/accounts/send_email_verification.js +1 -0
- package/dist/app/accounts/set_account_cookie.js +1 -0
- package/dist/app/accounts/set_password.js +1 -0
- package/dist/app/accounts/signup.js +1 -97
- package/dist/app/accounts/unset_account_cookie.js +1 -0
- package/dist/app/accounts/verify_email.js +1 -0
- package/dist/app/api/accounts/authenticated.js +1 -0
- package/dist/app/api/accounts/login.js +1 -0
- package/dist/app/api/accounts/logout.js +1 -0
- package/dist/app/api/accounts/recover_password.js +1 -0
- package/dist/app/api/accounts/reset_password.js +1 -0
- package/dist/app/api/accounts/signup.js +1 -0
- package/dist/app/api/accounts/user.js +1 -0
- package/dist/app/api/accounts/verify_email.js +1 -0
- package/dist/app/api/format_api_error.js +1 -0
- package/dist/app/api/get.js +2 -0
- package/dist/app/api/get_api_context.js +1 -0
- package/dist/app/api/get_api_for_data_functions.js +1 -0
- package/dist/app/api/get_api_url_component.js +1 -0
- package/dist/app/api/get_output.js +1 -0
- package/dist/app/api/get_value_from_object.js +1 -0
- package/dist/app/api/handle_api_error.js +1 -0
- package/dist/app/api/input_validators.js +1 -0
- package/dist/app/api/is_array_path.js +1 -0
- package/dist/app/api/push/health.js +2 -0
- package/dist/app/api/register_getters.js +1 -0
- package/dist/app/api/register_setters.js +1 -0
- package/dist/app/api/sanitize_api_response.js +1 -0
- package/dist/app/api/set.js +2 -0
- package/dist/app/api/test/accounts/delete.js +1 -0
- package/dist/app/api/test/accounts/signup.js +1 -0
- package/dist/app/api/test/bootstrap.js +1 -0
- package/dist/app/api/test/process.js +1 -0
- package/dist/app/api/test/queues.js +1 -0
- package/dist/app/api/validate_input.js +1 -0
- package/dist/app/api/validate_session.js +1 -0
- package/dist/app/api/validate_type.js +1 -0
- package/dist/app/browser/hmr_client.js +1 -0
- package/dist/app/browser/process_polyfill.js +1 -0
- package/dist/app/cron_jobs/register.js +1 -0
- package/dist/app/databases/database_type_map.js +1 -0
- package/dist/app/databases/get_target_database_connection.js +1 -0
- package/dist/app/databases/mongodb/available_query_parameters.js +1 -0
- package/dist/app/databases/mongodb/build_connection_string.js +1 -0
- package/dist/app/databases/mongodb/build_query_parameters.js +1 -0
- package/dist/app/databases/mongodb/connect.js +6 -0
- package/dist/app/databases/mongodb/create_indexes.js +1 -0
- package/dist/app/databases/postgresql/accounts/create_accounts_metadata_table_columns.js +1 -0
- package/dist/app/databases/postgresql/connect.js +30 -0
- package/dist/app/databases/postgresql/create_indexes.js +1 -0
- package/dist/app/databases/postgresql/create_tables.js +1 -0
- package/dist/app/databases/postgresql/handle_cleanup_queues.js +5 -0
- package/dist/app/databases/postgresql/handle_cleanup_sessions.js +1 -0
- package/dist/app/databases/queries/accounts.js +1 -0
- package/dist/app/databases/queries/map.js +1 -0
- package/dist/app/databases/queries/mongodb/accounts.js +1 -0
- package/dist/app/databases/queries/mongodb/queues.js +1 -0
- package/dist/app/databases/queries/mongodb/sessions.js +1 -0
- package/dist/app/databases/queries/postgresql/accounts.js +1 -0
- package/dist/app/databases/queries/postgresql/queues.js +123 -0
- package/dist/app/databases/queries/postgresql/sessions.js +14 -0
- package/dist/app/databases/queries/sessions.js +1 -0
- package/dist/app/databases/register_database.js +1 -0
- package/dist/app/databases/sql.js +1 -0
- package/dist/app/email/send.js +1 -0
- package/dist/app/email/validate_smtp_settings.js +1 -0
- package/dist/app/fixture/index.js +1 -0
- package/dist/app/generate_machine_id.js +1 -0
- package/dist/app/generate_process_id.js +1 -0
- package/dist/app/get_ssl_certificates.js +1 -0
- package/dist/app/handle_process_errors.js +1 -0
- package/dist/app/index.js +1 -656
- package/dist/app/middleware/account.js +1 -0
- package/dist/app/middleware/body_parser.js +1 -0
- package/dist/app/middleware/build_error.js +1 -0
- package/dist/app/middleware/built_in.js +1 -0
- package/dist/app/middleware/context.js +1 -0
- package/dist/app/middleware/cors.js +1 -22
- package/dist/app/middleware/csp.js +1 -48
- package/dist/app/middleware/generate_insecure_page.js +65 -0
- package/dist/app/middleware/generate_joystick_error_page.js +147 -0
- package/dist/app/middleware/hmr_client.js +1 -0
- package/dist/app/middleware/insecure.js +1 -11
- package/dist/app/middleware/process_browser_polyfill.js +1 -0
- package/dist/app/middleware/render/get_url.js +1 -0
- package/dist/app/middleware/render/index.js +1 -0
- package/dist/app/middleware/request_methods.js +1 -0
- package/dist/app/middleware/session.js +1 -24
- package/dist/app/push_logs.js +1 -0
- package/dist/app/queues/index.js +1 -119
- package/dist/app/register_app_options.js +1 -0
- package/dist/app/routes/register_route_from_function.js +1 -0
- package/dist/app/routes/register_route_from_object.js +1 -0
- package/dist/app/routes/supported_http_methods.js +1 -0
- package/dist/app/settings/load.js +1 -0
- package/dist/app/ssr/index.js +33 -0
- package/dist/app/ssr/set_base_attributes_in_html.js +1 -0
- package/dist/app/ssr/set_head_tags_in_html.js +1 -0
- package/dist/app/start_express.js +1 -0
- package/dist/app/start_node_as_cluster.js +1 -0
- package/dist/app/uploaders/local_upload_progress_middleware.js +1 -0
- package/dist/app/uploaders/register.js +1 -0
- package/dist/app/uploaders/run_upload.js +1 -0
- package/dist/app/uploaders/validate_options.js +1 -0
- package/dist/app/uploaders/validate_uploads.js +1 -0
- package/dist/app/websockets/emit_event.js +1 -0
- package/dist/app/websockets/index.js +1 -0
- package/dist/app/websockets/register.js +1 -0
- package/dist/index.js +4 -76
- package/dist/lib/camel_pascal_to_snake.js +1 -0
- package/dist/lib/constants.js +1 -13
- package/dist/lib/dynamic_import.js +1 -0
- package/dist/lib/escape_html.js +1 -0
- package/dist/lib/escape_key_value_pair.js +1 -0
- package/dist/lib/float_to_decimal_place.js +1 -0
- package/dist/lib/generate_id.js +1 -0
- package/dist/lib/get_browser_safe_request.js +1 -0
- package/dist/lib/get_joystick_build_path.js +1 -0
- package/dist/lib/get_origin.js +1 -0
- package/dist/lib/get_platform_safe_path.js +1 -0
- package/dist/lib/get_sanitized_context.js +1 -0
- package/dist/lib/get_translations.js +1 -0
- package/dist/lib/hash_string.js +1 -0
- package/dist/lib/is_valid_json.js +1 -0
- package/dist/lib/log.js +13 -49
- package/dist/lib/node_path_polyfills.js +1 -0
- package/dist/lib/parse_json.js +1 -0
- package/dist/lib/path_exists.js +1 -0
- package/dist/lib/rainbow_road.js +1 -0
- package/dist/lib/serialize_query_parameters.js +1 -0
- package/dist/lib/set_cookie.js +1 -0
- package/dist/lib/string_to_slug.js +1 -0
- package/dist/lib/timestamps.js +1 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/unset_cookie.js +1 -0
- package/dist/lib/wait.js +1 -0
- package/dist/test/track_function_call.js +1 -0
- package/increment_version.js +3 -0
- package/package.json +27 -44
- package/src/action/class.js +137 -0
- package/src/action/index.js +8 -0
- package/src/app/accounts/default_user_output_fields.js +10 -0
- package/src/app/accounts/delete_user.js +18 -0
- package/src/app/accounts/generate_account_session.js +11 -0
- package/src/app/accounts/generate_password_reset_token.js +16 -0
- package/src/app/accounts/get_browser_safe_user.js +29 -0
- package/src/app/accounts/has_login_token_expired.js +9 -0
- package/src/app/accounts/index.js +38 -0
- package/src/app/accounts/login.js +82 -0
- package/src/app/accounts/recover_password.js +58 -0
- package/src/app/accounts/reset_password.js +69 -0
- package/src/app/accounts/roles/add.js +7 -0
- package/src/app/accounts/roles/grant.js +7 -0
- package/src/app/accounts/roles/index.js +18 -0
- package/src/app/accounts/roles/list.js +7 -0
- package/src/app/accounts/roles/remove.js +7 -0
- package/src/app/accounts/roles/revoke.js +7 -0
- package/src/app/accounts/roles/user_has_role.js +7 -0
- package/src/app/accounts/send_email_verification.js +48 -0
- package/src/app/accounts/set_account_cookie.js +12 -0
- package/src/app/accounts/set_password.js +46 -0
- package/src/app/accounts/signup.js +158 -0
- package/src/app/accounts/unset_account_cookie.js +12 -0
- package/src/app/accounts/verify_email.js +32 -0
- package/src/app/api/accounts/authenticated.js +17 -0
- package/src/app/api/accounts/login.js +36 -0
- package/src/app/api/accounts/logout.js +20 -0
- package/src/app/api/accounts/recover_password.js +16 -0
- package/src/app/api/accounts/reset_password.js +24 -0
- package/src/app/api/accounts/signup.js +49 -0
- package/src/app/api/accounts/user.js +21 -0
- package/src/app/api/accounts/verify_email.js +11 -0
- package/src/app/api/format_api_error.js +10 -0
- package/src/app/api/get.js +119 -0
- package/src/app/api/get_api_context.js +27 -0
- package/src/app/api/get_api_for_data_functions.js +37 -0
- package/src/app/api/get_api_url_component.js +5 -0
- package/src/app/api/get_output.js +116 -0
- package/src/app/api/get_value_from_object.js +8 -0
- package/src/app/api/handle_api_error.js +28 -0
- package/src/app/api/input_validators.js +227 -0
- package/src/app/api/is_array_path.js +6 -0
- package/src/app/api/push/health.js +17 -0
- package/src/app/api/register_getters.js +57 -0
- package/src/app/api/register_setters.js +55 -0
- package/src/app/api/sanitize_api_response.js +35 -0
- package/src/app/api/set.js +119 -0
- package/src/app/api/test/accounts/delete.js +8 -0
- package/src/app/api/test/accounts/signup.js +50 -0
- package/src/app/api/test/bootstrap.js +39 -0
- package/src/app/api/test/process.js +7 -0
- package/src/app/api/test/queues.js +25 -0
- package/src/app/api/validate_input.js +130 -0
- package/src/app/api/validate_session.js +20 -0
- package/src/app/api/validate_type.js +24 -0
- package/src/app/browser/hmr_client.js +196 -0
- package/src/app/browser/process_polyfill.js +11 -0
- package/src/app/cron_jobs/register.js +29 -0
- package/src/app/databases/database_type_map.js +6 -0
- package/src/app/databases/get_target_database_connection.js +25 -0
- package/{dist/app/databases/mongodb/availableQueryParameters.js → src/app/databases/mongodb/available_query_parameters.js} +3 -4
- package/src/app/databases/mongodb/build_connection_string.js +30 -0
- package/src/app/databases/mongodb/build_query_parameters.js +17 -0
- package/src/app/databases/mongodb/connect.js +42 -0
- package/src/app/databases/mongodb/create_indexes.js +35 -0
- package/src/app/databases/postgresql/accounts/create_accounts_metadata_table_columns.js +18 -0
- package/src/app/databases/postgresql/connect.js +128 -0
- package/src/app/databases/postgresql/create_indexes.js +58 -0
- package/src/app/databases/postgresql/create_tables.js +70 -0
- package/src/app/databases/postgresql/handle_cleanup_queues.js +36 -0
- package/src/app/databases/postgresql/handle_cleanup_sessions.js +5 -0
- package/src/app/databases/queries/accounts.js +17 -0
- package/src/app/databases/queries/map.js +21 -0
- package/src/app/databases/queries/mongodb/accounts.js +360 -0
- package/src/app/databases/queries/mongodb/queues.js +164 -0
- package/src/app/databases/queries/mongodb/sessions.js +22 -0
- package/src/app/databases/queries/postgresql/accounts.js +379 -0
- package/src/app/databases/queries/postgresql/queues.js +294 -0
- package/src/app/databases/queries/postgresql/sessions.js +37 -0
- package/src/app/databases/queries/sessions.js +17 -0
- package/src/app/databases/register_database.js +30 -0
- package/src/app/databases/sql.js +63 -0
- package/src/app/email/send.js +108 -0
- package/src/app/email/validate_smtp_settings.js +53 -0
- package/src/app/fixture/index.js +50 -0
- package/src/app/generate_machine_id.js +26 -0
- package/src/app/generate_process_id.js +30 -0
- package/src/app/get_ssl_certificates.js +23 -0
- package/src/app/handle_process_errors.js +101 -0
- package/src/app/index.js +253 -0
- package/src/app/middleware/account.js +28 -0
- package/src/app/middleware/body_parser.js +18 -0
- package/src/app/middleware/build_error.js +18 -0
- package/src/app/middleware/built_in.js +76 -0
- package/src/app/middleware/context.js +34 -0
- package/src/app/middleware/cors.js +23 -0
- package/src/app/middleware/csp.js +54 -0
- package/src/app/middleware/generate_insecure_page.js +71 -0
- package/{dist/lib/generateErrorPage.js → src/app/middleware/generate_joystick_error_page.js} +25 -21
- package/src/app/middleware/hmr_client.js +12 -0
- package/src/app/middleware/insecure.js +22 -0
- package/src/app/middleware/process_browser_polyfill.js +12 -0
- package/src/app/middleware/render/get_url.js +15 -0
- package/src/app/middleware/render/index.js +93 -0
- package/src/app/middleware/request_methods.js +21 -0
- package/src/app/middleware/session.js +31 -0
- package/src/app/push_logs.js +44 -0
- package/src/app/queues/index.js +268 -0
- package/src/app/register_app_options.js +7 -0
- package/src/app/routes/register_route_from_function.js +10 -0
- package/src/app/routes/register_route_from_object.js +34 -0
- package/src/app/routes/supported_http_methods.js +9 -0
- package/src/app/settings/load.js +33 -0
- package/src/app/ssr/index.js +133 -0
- package/src/app/ssr/set_base_attributes_in_html.js +43 -0
- package/src/app/ssr/set_head_tags_in_html.js +104 -0
- package/src/app/start_express.js +50 -0
- package/src/app/start_node_as_cluster.js +30 -0
- package/src/app/uploaders/local_upload_progress_middleware.js +24 -0
- package/src/app/uploaders/register.js +169 -0
- package/src/app/uploaders/run_upload.js +136 -0
- package/src/app/uploaders/validate_options.js +74 -0
- package/src/app/uploaders/validate_uploads.js +127 -0
- package/src/app/websockets/emit_event.js +14 -0
- package/src/app/websockets/index.js +16 -0
- package/src/app/websockets/register.js +175 -0
- package/src/index.js +81 -0
- package/{dist/lib/camelPascalToSnake.js → src/lib/camel_pascal_to_snake.js} +3 -4
- package/src/lib/constants.js +21 -0
- package/src/lib/dynamic_import.js +8 -0
- package/src/lib/escape_html.js +9 -0
- package/src/lib/escape_key_value_pair.js +15 -0
- package/src/lib/float_to_decimal_place.js +5 -0
- package/src/lib/generate_id.js +15 -0
- package/src/lib/get_browser_safe_request.js +17 -0
- package/src/lib/get_joystick_build_path.js +22 -0
- package/src/lib/get_origin.js +7 -0
- package/src/lib/get_platform_safe_path.js +8 -0
- package/src/lib/get_sanitized_context.js +51 -0
- package/src/lib/get_translations.js +109 -0
- package/src/lib/hash_string.js +7 -0
- package/src/lib/is_valid_json.js +10 -0
- package/src/lib/log.js +42 -0
- package/src/lib/node_path_polyfills.js +23 -0
- package/src/lib/parse_json.js +9 -0
- package/src/lib/path_exists.js +12 -0
- package/src/lib/rainbow_road.js +7 -0
- package/src/lib/serialize_query_parameters.js +7 -0
- package/src/lib/set_cookie.js +16 -0
- package/src/lib/string_to_slug.js +14 -0
- package/src/lib/timestamps.js +48 -0
- package/src/lib/types.js +59 -0
- package/src/lib/unset_cookie.js +11 -0
- package/src/lib/wait.js +9 -0
- package/src/test/track_function_call.js +16 -0
- package/README.md +0 -8
- package/_package.json +0 -63
- package/canary.js +0 -12
- package/dist/api/get.js +0 -29
- package/dist/api/getOrigin.js +0 -6
- package/dist/api/index.js +0 -9
- package/dist/api/set.js +0 -29
- package/dist/app/accounts/defaultUserOutputFields.js +0 -9
- package/dist/app/accounts/generateResetToken.js +0 -28
- package/dist/app/accounts/generateSession.js +0 -15
- package/dist/app/accounts/getBrowserSafeUser.js +0 -24
- package/dist/app/accounts/hasLoginTokenExpired.js +0 -17
- package/dist/app/accounts/hashString.js +0 -7
- package/dist/app/accounts/recoverPassword.js +0 -30
- package/dist/app/accounts/resetPassword.js +0 -73
- package/dist/app/accounts/roles/userHasRole.js +0 -7
- package/dist/app/accounts/runUserQuery.js +0 -15
- package/dist/app/accounts/sendEmailVerification.js +0 -65
- package/dist/app/accounts/setAuthenticationCookie.js +0 -11
- package/dist/app/accounts/setPassword.js +0 -45
- package/dist/app/accounts/unsetAuthenticationCookie.js +0 -11
- package/dist/app/accounts/verifyEmail.js +0 -46
- package/dist/app/databases/getTargetDatabase.js +0 -10
- package/dist/app/databases/getTargetDatabaseConnection.js +0 -19
- package/dist/app/databases/getTargetDatabaseProvider.js +0 -10
- package/dist/app/databases/mongodb/buildConnectionString.js +0 -22
- package/dist/app/databases/mongodb/buildQueryParameters.js +0 -14
- package/dist/app/databases/mongodb/index.js +0 -40
- package/dist/app/databases/mongodb/queries/accounts.js +0 -266
- package/dist/app/databases/mongodb/queries/queues.js +0 -111
- package/dist/app/databases/postgresql/addColumnToTable.js +0 -6
- package/dist/app/databases/postgresql/createAccountsIndexes.js +0 -21
- package/dist/app/databases/postgresql/createAccountsTables.js +0 -39
- package/dist/app/databases/postgresql/createDatabase.js +0 -0
- package/dist/app/databases/postgresql/index.js +0 -55
- package/dist/app/databases/postgresql/queries/accounts.js +0 -186
- package/dist/app/databases/postgresql/queries/queues.js +0 -211
- package/dist/app/databases/queryMap.js +0 -17
- package/dist/app/databases/typesMap.js +0 -7
- package/dist/app/getAPIContext.js +0 -25
- package/dist/app/getAPIURLComponent.js +0 -6
- package/dist/app/getBrowserSafeRequest.js +0 -14
- package/dist/app/getOutput.js +0 -74
- package/dist/app/handleProcessErrors.js +0 -73
- package/dist/app/initExpress.js +0 -41
- package/dist/app/middleware/bodyParser.js +0 -16
- package/dist/app/middleware/hmr/client.js +0 -113
- package/dist/app/middleware/index.js +0 -89
- package/dist/app/middleware/render.js +0 -213
- package/dist/app/middleware/requestMethods.js +0 -19
- package/dist/app/registerGetters.js +0 -45
- package/dist/app/registerSetters.js +0 -45
- package/dist/app/runGetter.js +0 -103
- package/dist/app/runSetter.js +0 -103
- package/dist/app/runUploader.js +0 -143
- package/dist/app/sanitizeAPIResponse.js +0 -27
- package/dist/app/utils/process.js +0 -193
- package/dist/app/validateSession.js +0 -19
- package/dist/app/validateUploaderOptions.js +0 -53
- package/dist/app/validateUploads.js +0 -102
- package/dist/email/render.js +0 -50
- package/dist/email/send.js +0 -55
- package/dist/email/templates/base.css +0 -194
- package/dist/email/templates/base.html +0 -28
- package/dist/email/templates/reset-password.js +0 -13
- package/dist/email/validateSMTPSettings.js +0 -27
- package/dist/lib/escapeHTML.js +0 -9
- package/dist/lib/escapeKeyValuePair.js +0 -13
- package/dist/lib/formatAPIError.js +0 -12
- package/dist/lib/formatErrorString.js +0 -8
- package/dist/lib/generateCookie.js +0 -14
- package/dist/lib/generateId.js +0 -13
- package/dist/lib/generateMachineId.js +0 -15
- package/dist/lib/getBuildPath.js +0 -10
- package/dist/lib/getErrorObject.js +0 -9
- package/dist/lib/getPlatformSafeFilePath.js +0 -8
- package/dist/lib/getPlatformSafePath.js +0 -8
- package/dist/lib/getSSLCertificates.js +0 -19
- package/dist/lib/isValidHTTPMethod.js +0 -7
- package/dist/lib/isValidJSONString.js +0 -11
- package/dist/lib/nodeUrlPolyfills.js +0 -14
- package/dist/lib/objectToSQLKeysString.js +0 -18
- package/dist/lib/objectToSQLValuesString.js +0 -16
- package/dist/lib/obscenedb/debounce.js +0 -12
- package/dist/lib/obscenedb/index.js +0 -61
- package/dist/lib/parseDatabasesFromEnvironment.js +0 -9
- package/dist/lib/rainbowRoad.js +0 -7
- package/dist/lib/readDirectory.js +0 -24
- package/dist/lib/replaceBackslashesWithForwardSlashes.js +0 -8
- package/dist/lib/replaceFileProtocol.js +0 -8
- package/dist/lib/replaceForwardSlashesWithBackslashes.js +0 -8
- package/dist/lib/serializeQueryParameters.js +0 -8
- package/dist/lib/serverAvailable.js +0 -0
- package/dist/lib/setCookie.js +0 -16
- package/dist/lib/supportedHTTPMethods.js +0 -4
- package/dist/lib/unsetCookie.js +0 -13
- package/dist/push/logs/index.js +0 -55
- package/dist/settings/index.js +0 -5
- package/dist/settings/load.js +0 -30
- package/dist/ssr/compileCSS.js +0 -85
- package/dist/ssr/findComponentInTree.js +0 -29
- package/dist/ssr/formatCSS.js +0 -6
- package/dist/ssr/getCSSFromTree.js +0 -33
- package/dist/ssr/index.js +0 -441
- package/dist/ssr/replaceWhenTags.js +0 -37
- package/dist/ssr/setHeadTagsInHTML.js +0 -84
- package/dist/validation/index.js +0 -10
- package/dist/validation/index.test.js +0 -463
- package/dist/validation/inputWithSchema/index.js +0 -105
- package/dist/validation/lib/constants.js +0 -162
- package/dist/validation/lib/getValueFromObject.js +0 -12
- package/dist/validation/lib/getValueFromObject.test.js +0 -7
- package/dist/validation/lib/isArrayPath.js +0 -6
- package/dist/validation/lib/throwError.js +0 -6
- package/dist/validation/lib/typeValidators.js +0 -38
- package/dist/validation/lib/validateType.js +0 -33
- package/dist/validation/schema/index.js +0 -44
- package/dist/websockets/emitWebsocketEvent.js +0 -12
- package/dist/websockets/index.js +0 -12
- package/notes +0 -1
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import dayjs from "dayjs";
|
|
2
|
-
var queues_default = {
|
|
3
|
-
addJob: function(jobToAdd = {}) {
|
|
4
|
-
const db = process.databases._queues;
|
|
5
|
-
return db?.query(`
|
|
6
|
-
INSERT INTO queue_${this.queue.name} (
|
|
7
|
-
_id,
|
|
8
|
-
status,
|
|
9
|
-
job,
|
|
10
|
-
payload,
|
|
11
|
-
next_run_at
|
|
12
|
-
) VALUES (
|
|
13
|
-
$1, $2, $3, $4, $5
|
|
14
|
-
)
|
|
15
|
-
`, [
|
|
16
|
-
jobToAdd?._id,
|
|
17
|
-
jobToAdd?.status,
|
|
18
|
-
jobToAdd?.job,
|
|
19
|
-
JSON.stringify(jobToAdd?.payload),
|
|
20
|
-
jobToAdd?.nextRunAt
|
|
21
|
-
]);
|
|
22
|
-
},
|
|
23
|
-
countJobs: async function(status = "") {
|
|
24
|
-
const db = process.databases._queues;
|
|
25
|
-
const [jobs] = await db?.query(`
|
|
26
|
-
SELECT
|
|
27
|
-
count(*)
|
|
28
|
-
FROM
|
|
29
|
-
queue_${this.queue.name}
|
|
30
|
-
WHERE
|
|
31
|
-
status = $1
|
|
32
|
-
`, [
|
|
33
|
-
status
|
|
34
|
-
]);
|
|
35
|
-
return Promise.resolve(jobs.count);
|
|
36
|
-
},
|
|
37
|
-
deleteJob: function(jobId = "") {
|
|
38
|
-
const db = process.databases._queues;
|
|
39
|
-
return db?.query(`
|
|
40
|
-
DELETE FROM
|
|
41
|
-
queue_${this.queue.name}
|
|
42
|
-
WHERE
|
|
43
|
-
_id = $1
|
|
44
|
-
`, [
|
|
45
|
-
jobId
|
|
46
|
-
]);
|
|
47
|
-
},
|
|
48
|
-
getJobs: function(query = {}) {
|
|
49
|
-
const db = process.databases._queues;
|
|
50
|
-
return db?.query(`
|
|
51
|
-
SELECT * FROM
|
|
52
|
-
queue_${this.queue.name}
|
|
53
|
-
${query?.status ? `
|
|
54
|
-
WHERE
|
|
55
|
-
status = $1
|
|
56
|
-
` : ""}
|
|
57
|
-
`, [
|
|
58
|
-
query?.status
|
|
59
|
-
]);
|
|
60
|
-
},
|
|
61
|
-
getNextJobToRun: async function() {
|
|
62
|
-
const db = process.databases._queues;
|
|
63
|
-
const [nextJob] = await db?.query(`
|
|
64
|
-
SELECT * FROM
|
|
65
|
-
queue_${this.queue.name}
|
|
66
|
-
WHERE
|
|
67
|
-
status = $1
|
|
68
|
-
AND
|
|
69
|
-
next_run_at::date <= NOW()
|
|
70
|
-
AND
|
|
71
|
-
locked_by IS NULL
|
|
72
|
-
ORDER BY
|
|
73
|
-
next_run_at ASC
|
|
74
|
-
`, [
|
|
75
|
-
"pending"
|
|
76
|
-
]);
|
|
77
|
-
if (nextJob?._id) {
|
|
78
|
-
await db?.query(`
|
|
79
|
-
UPDATE
|
|
80
|
-
queue_${this.queue.name}
|
|
81
|
-
SET
|
|
82
|
-
status = $1,
|
|
83
|
-
started_at = $2,
|
|
84
|
-
locked_by = $3
|
|
85
|
-
WHERE
|
|
86
|
-
_id = $4
|
|
87
|
-
`, [
|
|
88
|
-
"running",
|
|
89
|
-
dayjs().format(),
|
|
90
|
-
this.machineId,
|
|
91
|
-
nextJob?._id
|
|
92
|
-
]);
|
|
93
|
-
}
|
|
94
|
-
return nextJob ? {
|
|
95
|
-
...nextJob,
|
|
96
|
-
payload: nextJob?.payload ? JSON.parse(nextJob?.payload || "") : {}
|
|
97
|
-
} : {};
|
|
98
|
-
},
|
|
99
|
-
initializeDatabase: async function() {
|
|
100
|
-
const db = process.databases._queues;
|
|
101
|
-
await db?.query(`
|
|
102
|
-
CREATE TABLE IF NOT EXISTS queue_${this.queue.name} (
|
|
103
|
-
_id text PRIMARY KEY,
|
|
104
|
-
status text,
|
|
105
|
-
job text,
|
|
106
|
-
payload text,
|
|
107
|
-
next_run_at text,
|
|
108
|
-
locked_by text,
|
|
109
|
-
started_at text,
|
|
110
|
-
completed_at text,
|
|
111
|
-
failed_at text,
|
|
112
|
-
error text
|
|
113
|
-
)
|
|
114
|
-
`);
|
|
115
|
-
db?.query(`CREATE INDEX IF NOT EXISTS status_index ON queue_${this.queue.name} (status)`);
|
|
116
|
-
db?.query(`CREATE INDEX IF NOT EXISTS status_nextRunAt_index ON queue_${this.queue.name} (status, next_run_at)`);
|
|
117
|
-
db?.query(`CREATE INDEX IF NOT EXISTS completedAt_index ON queue_${this.queue.name} (completed_at)`);
|
|
118
|
-
db?.query(`CREATE INDEX IF NOT EXISTS failedAt_index ON queue_${this.queue.name} (failed_at)`);
|
|
119
|
-
},
|
|
120
|
-
requeueJob: function(jobId = "", nextRunAt = null) {
|
|
121
|
-
const db = process.databases._queues;
|
|
122
|
-
return db?.query(`
|
|
123
|
-
UPDATE
|
|
124
|
-
queue_${this.queue.name}
|
|
125
|
-
SET
|
|
126
|
-
status = $1,
|
|
127
|
-
next_run_at = $2,
|
|
128
|
-
locked_by = $3
|
|
129
|
-
WHERE
|
|
130
|
-
_id = $4
|
|
131
|
-
`, [
|
|
132
|
-
"pending",
|
|
133
|
-
nextRunAt,
|
|
134
|
-
null,
|
|
135
|
-
jobId
|
|
136
|
-
]);
|
|
137
|
-
},
|
|
138
|
-
setJobsForMachineIncomplete: function() {
|
|
139
|
-
const db = process.databases._queues;
|
|
140
|
-
return db?.query(`
|
|
141
|
-
UPDATE
|
|
142
|
-
queue_${this.queue.name}
|
|
143
|
-
SET
|
|
144
|
-
status = $1
|
|
145
|
-
WHERE
|
|
146
|
-
status = $2
|
|
147
|
-
AND
|
|
148
|
-
locked_by = $3
|
|
149
|
-
`, [
|
|
150
|
-
"incomplete",
|
|
151
|
-
"running",
|
|
152
|
-
this.machineId
|
|
153
|
-
]);
|
|
154
|
-
},
|
|
155
|
-
setJobCompleted: function(jobId = "") {
|
|
156
|
-
const db = process.databases._queues;
|
|
157
|
-
return db?.query(`
|
|
158
|
-
UPDATE
|
|
159
|
-
queue_${this.queue.name}
|
|
160
|
-
SET
|
|
161
|
-
status = $1,
|
|
162
|
-
completed_at = $2
|
|
163
|
-
WHERE
|
|
164
|
-
_id = $3
|
|
165
|
-
`, [
|
|
166
|
-
"completed",
|
|
167
|
-
dayjs().format(),
|
|
168
|
-
jobId
|
|
169
|
-
]);
|
|
170
|
-
},
|
|
171
|
-
setJobFailed: function(jobId = "", error = "") {
|
|
172
|
-
const db = process.databases._queues;
|
|
173
|
-
return db?.query(`
|
|
174
|
-
UPDATE
|
|
175
|
-
queue_${this.queue.name}
|
|
176
|
-
SET
|
|
177
|
-
status = $1,
|
|
178
|
-
failed_at = $2,
|
|
179
|
-
error = $3
|
|
180
|
-
WHERE
|
|
181
|
-
_id = $4
|
|
182
|
-
`, [
|
|
183
|
-
"failed",
|
|
184
|
-
dayjs().format(),
|
|
185
|
-
error,
|
|
186
|
-
jobId
|
|
187
|
-
]);
|
|
188
|
-
},
|
|
189
|
-
setJobsForMachinePending: function() {
|
|
190
|
-
const db = process.databases._queues;
|
|
191
|
-
return db?.query(`
|
|
192
|
-
UPDATE
|
|
193
|
-
queue_${this.queue.name}
|
|
194
|
-
SET
|
|
195
|
-
status = $1,
|
|
196
|
-
locked_by = $2
|
|
197
|
-
WHERE
|
|
198
|
-
status = ANY($3)
|
|
199
|
-
AND
|
|
200
|
-
locked_by = $4
|
|
201
|
-
`, [
|
|
202
|
-
"pending",
|
|
203
|
-
null,
|
|
204
|
-
["pending", "running"],
|
|
205
|
-
this.machineId
|
|
206
|
-
]);
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
export {
|
|
210
|
-
queues_default as default
|
|
211
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import mongodbAccountsQueries from "./mongodb/queries/accounts";
|
|
2
|
-
import mongodbQueuesQueries from "./mongodb/queries/queues";
|
|
3
|
-
import postgresqlAccountsQueries from "./postgresql/queries/accounts";
|
|
4
|
-
import postgresqlQueuesQueries from "./postgresql/queries/queues";
|
|
5
|
-
var queryMap_default = {
|
|
6
|
-
mongodb: {
|
|
7
|
-
accounts: mongodbAccountsQueries,
|
|
8
|
-
queues: mongodbQueuesQueries
|
|
9
|
-
},
|
|
10
|
-
postgresql: {
|
|
11
|
-
accounts: postgresqlAccountsQueries,
|
|
12
|
-
queues: postgresqlQueuesQueries
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
export {
|
|
16
|
-
queryMap_default as default
|
|
17
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import parseDatabasesFromEnvironment from "../lib/parseDatabasesFromEnvironment.js";
|
|
2
|
-
var getAPIContext_default = (httpContext = {}, context = null) => {
|
|
3
|
-
return new Promise(async (resolve, reject) => {
|
|
4
|
-
if (typeof context === "function") {
|
|
5
|
-
const compiledContext = await context(httpContext.req, httpContext.res);
|
|
6
|
-
return resolve({
|
|
7
|
-
...compiledContext,
|
|
8
|
-
...httpContext?.req?.context || {},
|
|
9
|
-
req: httpContext.req,
|
|
10
|
-
res: httpContext.res,
|
|
11
|
-
...process.databases || {}
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
return resolve({
|
|
15
|
-
...context,
|
|
16
|
-
...httpContext?.req?.context || {},
|
|
17
|
-
req: httpContext.req,
|
|
18
|
-
res: httpContext.res,
|
|
19
|
-
...process.databases || {}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
export {
|
|
24
|
-
getAPIContext_default as default
|
|
25
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import getBrowserSafeUser from "./accounts/getBrowserSafeUser";
|
|
2
|
-
import escapeKeyValuePair from "../lib/escapeKeyValuePair.js";
|
|
3
|
-
var getBrowserSafeRequest_default = (req = {}) => {
|
|
4
|
-
const browserSafeRequest = {};
|
|
5
|
-
browserSafeRequest.params = escapeKeyValuePair(req.params);
|
|
6
|
-
browserSafeRequest.query = escapeKeyValuePair(req.query);
|
|
7
|
-
browserSafeRequest.context = {
|
|
8
|
-
user: getBrowserSafeUser(req.context.user)
|
|
9
|
-
};
|
|
10
|
-
return browserSafeRequest;
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
getBrowserSafeRequest_default as default
|
|
14
|
-
};
|
package/dist/app/getOutput.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { isObject } from "../validation/lib/typeValidators";
|
|
2
|
-
const getOutput = (object = {}, fields = []) => {
|
|
3
|
-
Object.entries(object || {}).forEach(([key, value]) => {
|
|
4
|
-
const keyInFields = fields.find((field) => field.key === key);
|
|
5
|
-
if (!keyInFields) {
|
|
6
|
-
delete object[key];
|
|
7
|
-
}
|
|
8
|
-
if (keyInFields && isObject(value) && keyInFields.children.length === 0) {
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
if (keyInFields && isObject(value) && keyInFields.children.length > 0) {
|
|
12
|
-
return getOutput(value, keyInFields.children);
|
|
13
|
-
}
|
|
14
|
-
if (keyInFields && Array.isArray(value) && keyInFields.children && keyInFields.children.length > 0) {
|
|
15
|
-
value.forEach((valueElement) => {
|
|
16
|
-
if (valueElement && isObject(valueElement)) {
|
|
17
|
-
return getOutput(valueElement, keyInFields.children);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
return object;
|
|
23
|
-
};
|
|
24
|
-
const getPathPartArrays = (paths = []) => {
|
|
25
|
-
return paths.map((path) => {
|
|
26
|
-
return path.split(".");
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
const getHeadTail = (pathPartArray = []) => {
|
|
30
|
-
const [head, ...tail] = pathPartArray;
|
|
31
|
-
return {
|
|
32
|
-
head,
|
|
33
|
-
tail
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
const getHeadTailForPaths = (pathPartArrays = []) => {
|
|
37
|
-
return pathPartArrays.map((pathPartArray) => {
|
|
38
|
-
return getHeadTail(pathPartArray);
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
const addToMap = (map = [], headTailForPaths = []) => {
|
|
42
|
-
headTailForPaths.forEach((headTailForPath) => {
|
|
43
|
-
const existingMapEntry = map.find((mapEntry) => mapEntry.key === headTailForPath.head);
|
|
44
|
-
if (!existingMapEntry) {
|
|
45
|
-
const headTailForChildren = headTailForPath.tail && headTailForPath.tail.length > 0 ? getHeadTail(headTailForPath.tail) : null;
|
|
46
|
-
map.push({
|
|
47
|
-
key: headTailForPath.head,
|
|
48
|
-
children: headTailForChildren ? addToMap([], [headTailForChildren]) : []
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (existingMapEntry) {
|
|
52
|
-
const headTailForChildren = headTailForPath.tail && headTailForPath.tail.length > 0 ? getHeadTail(headTailForPath.tail) : null;
|
|
53
|
-
existingMapEntry.children = [
|
|
54
|
-
...headTailForChildren ? addToMap(existingMapEntry.children, [headTailForChildren]) : []
|
|
55
|
-
];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
return map;
|
|
59
|
-
};
|
|
60
|
-
var getOutput_default = (output = {}, outputFields = []) => {
|
|
61
|
-
const map = [];
|
|
62
|
-
const pathPartArrays = getPathPartArrays(outputFields);
|
|
63
|
-
const headTailForPaths = getHeadTailForPaths(pathPartArrays);
|
|
64
|
-
addToMap(map, headTailForPaths);
|
|
65
|
-
if (Array.isArray(output)) {
|
|
66
|
-
return output.map((element) => {
|
|
67
|
-
return getOutput(element, map);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return getOutput(output, map);
|
|
71
|
-
};
|
|
72
|
-
export {
|
|
73
|
-
getOutput_default as default
|
|
74
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
var handleProcessErrors_default = (listeners = {}) => {
|
|
2
|
-
process.on("exit", async () => {
|
|
3
|
-
});
|
|
4
|
-
process.on("beforeExit", async (code) => {
|
|
5
|
-
if (listeners?.beforeExit && typeof listeners.beforeExit === "function") {
|
|
6
|
-
listeners.beforeExit(code);
|
|
7
|
-
}
|
|
8
|
-
});
|
|
9
|
-
process.on("disconnect", async () => {
|
|
10
|
-
if (listeners?.disconnect && typeof listeners.disconnect === "function") {
|
|
11
|
-
listeners.disconnect();
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
process.on("exit", async (code) => {
|
|
15
|
-
if (listeners?.exit && typeof listeners.exit === "function") {
|
|
16
|
-
listeners.exit(code);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
process.on("message", async (message, sendHandle) => {
|
|
20
|
-
if (process.env.NODE_ENV !== "test") {
|
|
21
|
-
console.log(message);
|
|
22
|
-
}
|
|
23
|
-
if (listeners?.message && typeof listeners.message === "function") {
|
|
24
|
-
listeners.message(message, sendHandle);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
process.on("multipleResolves", async (type, promise, value) => {
|
|
28
|
-
if (listeners?.multipleResolves && typeof listeners.multipleResolves === "function") {
|
|
29
|
-
listeners.multipleResolves(type, promise, value);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
process.on("rejectionHandled", async (promise) => {
|
|
33
|
-
if (listeners?.rejectionHandled && typeof listeners.rejectionHandled === "function") {
|
|
34
|
-
listeners.rejectionHandled(promise);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
process.on("uncaughtException", async (error, origin) => {
|
|
38
|
-
console.warn(error);
|
|
39
|
-
if (listeners?.error && typeof listeners.error === "function") {
|
|
40
|
-
listeners.error(error);
|
|
41
|
-
}
|
|
42
|
-
if (listeners?.uncaughtException && typeof listeners.uncaughtException === "function") {
|
|
43
|
-
listeners.uncaughtException(error, origin);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
process.on("uncaughtExceptionMonitor", async (error) => {
|
|
47
|
-
if (listeners?.uncaughtExceptionMonitor && typeof listeners.uncaughtExceptionMonitor === "function") {
|
|
48
|
-
listeners.uncaughtExceptionMonitor(error);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
process.on("unhandledRejection", async (error) => {
|
|
52
|
-
console.warn(error);
|
|
53
|
-
if (listeners?.error && typeof listeners.error === "function") {
|
|
54
|
-
listeners.error(error);
|
|
55
|
-
}
|
|
56
|
-
if (listeners?.unhandledRejection && typeof listeners.unhandledRejection === "function") {
|
|
57
|
-
listeners.unhandledRejection(error);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
process.on("warning", async (warning) => {
|
|
61
|
-
if (listeners?.warning && typeof listeners.warning === "function") {
|
|
62
|
-
listeners.warning(warning);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
process.on("worker", async (event) => {
|
|
66
|
-
if (listeners?.worker && typeof listeners.worker === "function") {
|
|
67
|
-
listeners.worker(event);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
export {
|
|
72
|
-
handleProcessErrors_default as default
|
|
73
|
-
};
|
package/dist/app/initExpress.js
DELETED
|
@@ -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
|
-
};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
// src/app/middleware/hmr/client.js
|
|
2
|
-
var reconnectInterval = null;
|
|
3
|
-
var reconnectAttempts = 0;
|
|
4
|
-
var websocketClient = (options = {}, onConnect = null) => {
|
|
5
|
-
let client = new WebSocket(`ws://localhost:${window.__joystick_hmr_port__}/_joystick/hmr`);
|
|
6
|
-
if (reconnectInterval) {
|
|
7
|
-
clearInterval(reconnectInterval);
|
|
8
|
-
reconnectInterval = null;
|
|
9
|
-
}
|
|
10
|
-
const connection = {
|
|
11
|
-
client,
|
|
12
|
-
send: (message = {}) => {
|
|
13
|
-
if (options.queryParams) {
|
|
14
|
-
message = { ...message, ...options.queryParams };
|
|
15
|
-
}
|
|
16
|
-
return client.send(JSON.stringify(message));
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
client.addEventListener("open", () => {
|
|
20
|
-
console.log(`[hmr] Listening for changes...`);
|
|
21
|
-
reconnectAttempts = 0;
|
|
22
|
-
if (onConnect)
|
|
23
|
-
onConnect(connection);
|
|
24
|
-
});
|
|
25
|
-
client.addEventListener("message", (event) => {
|
|
26
|
-
if (event?.data && options.onMessage) {
|
|
27
|
-
options.onMessage(JSON.parse(event.data), connection);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
client.addEventListener("close", () => {
|
|
31
|
-
console.log(`[hmr] Disconnected from server`);
|
|
32
|
-
client = null;
|
|
33
|
-
if (options.autoReconnect && !reconnectInterval) {
|
|
34
|
-
reconnectInterval = setInterval(() => {
|
|
35
|
-
client = null;
|
|
36
|
-
if (reconnectAttempts < 12) {
|
|
37
|
-
websocketClient(options, onConnect);
|
|
38
|
-
console.log(`[hmr] Attempting to reconnect (${reconnectAttempts + 1}/12)...`);
|
|
39
|
-
reconnectAttempts += 1;
|
|
40
|
-
} else {
|
|
41
|
-
console.log(`[hmr] Reconnection attempts exhausted. Server is unavailable.`);
|
|
42
|
-
clearInterval(reconnectInterval);
|
|
43
|
-
}
|
|
44
|
-
}, 5e3);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return connection;
|
|
48
|
-
};
|
|
49
|
-
var client_default = (() => websocketClient({
|
|
50
|
-
autoReconnect: true,
|
|
51
|
-
onMessage: async (message = {}, connection = {}) => {
|
|
52
|
-
const previous = Object.assign({}, { scrollTop: window.scrollY });
|
|
53
|
-
const isFileChange = message && message.type && message.type === "FILE_CHANGE";
|
|
54
|
-
const isPageInLayout = !!window.__joystick_layout_page__;
|
|
55
|
-
const CSS = document.head.querySelector('link[href="/_joystick/index.css"]');
|
|
56
|
-
const clientIndex = document.body.querySelector('script[src^="/_joystick/index.client.js"]');
|
|
57
|
-
if (message?.indexHTMLChanged) {
|
|
58
|
-
location.reload();
|
|
59
|
-
}
|
|
60
|
-
if (message?.settings) {
|
|
61
|
-
window.__joystick_settings__ = JSON.stringify(message?.settings);
|
|
62
|
-
window.joystick.settings = message?.settings;
|
|
63
|
-
}
|
|
64
|
-
if (clientIndex) {
|
|
65
|
-
clientIndex.parentNode.removeChild(clientIndex);
|
|
66
|
-
const updatedClientIndex = document.createElement("script");
|
|
67
|
-
updatedClientIndex.setAttribute("type", "text/javascript");
|
|
68
|
-
updatedClientIndex.setAttribute("src", `/_joystick/index.client.js?v=${new Date().getTime()}`);
|
|
69
|
-
document.body.appendChild(updatedClientIndex);
|
|
70
|
-
}
|
|
71
|
-
if (CSS) {
|
|
72
|
-
const updatedCSS = document.createElement("link");
|
|
73
|
-
updatedCSS.setAttribute("rel", "stylesheet");
|
|
74
|
-
updatedCSS.setAttribute("href", "/_joystick/index.css");
|
|
75
|
-
document.head.appendChild(updatedCSS);
|
|
76
|
-
}
|
|
77
|
-
if (isFileChange && isPageInLayout) {
|
|
78
|
-
(async () => {
|
|
79
|
-
window.__joystick_childrenBeforeHMRUpdate__ = window.joystick?._internal?.tree?.instance?.children;
|
|
80
|
-
const layoutComponentFile = await import(`${window.__joystick_layout__}?t=${new Date().getTime()}`);
|
|
81
|
-
const pageComponentFile = await import(`${window.window.__joystick_layout_page_url__}?t=${new Date().getTime()}`);
|
|
82
|
-
const layout = layoutComponentFile.default;
|
|
83
|
-
const page = pageComponentFile.default;
|
|
84
|
-
window.joystick.mount(layout, Object.assign({ page }, window.__joystick_ssr_props__), document.getElementById("app"));
|
|
85
|
-
if (connection.send) {
|
|
86
|
-
const sessions = await fetch(`${location.origin}/api/_joystick/sessions`)?.then((response) => response.text());
|
|
87
|
-
connection.send({ type: "HMR_UPDATE_COMPLETE", sessions });
|
|
88
|
-
}
|
|
89
|
-
})();
|
|
90
|
-
}
|
|
91
|
-
if (isFileChange && !isPageInLayout) {
|
|
92
|
-
(async () => {
|
|
93
|
-
window.__joystick_childrenBeforeHMRUpdate__ = window.joystick?._internal?.tree?.instance?.children;
|
|
94
|
-
const pageComponentFile = await import(`${window.__joystick_page_url__}?t=${new Date().getTime()}`);
|
|
95
|
-
const page = pageComponentFile.default;
|
|
96
|
-
window.joystick.mount(page, Object.assign({}, window.__joystick_ssr_props__), document.getElementById("app"));
|
|
97
|
-
if (connection.send) {
|
|
98
|
-
const sessions = await fetch(`${location.origin}/api/_joystick/sessions`)?.then((response) => response.strin());
|
|
99
|
-
connection.send({ type: "HMR_UPDATE_COMPLETE", sessions });
|
|
100
|
-
}
|
|
101
|
-
})();
|
|
102
|
-
}
|
|
103
|
-
if (CSS) {
|
|
104
|
-
setTimeout(() => {
|
|
105
|
-
CSS.parentNode.removeChild(CSS);
|
|
106
|
-
}, 1e3);
|
|
107
|
-
}
|
|
108
|
-
window.scrollTo(0, previous.scrollTop);
|
|
109
|
-
}
|
|
110
|
-
}))();
|
|
111
|
-
export {
|
|
112
|
-
client_default as default
|
|
113
|
-
};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import express from "express";
|
|
2
|
-
import compression from "compression";
|
|
3
|
-
import cookieParser from "cookie-parser";
|
|
4
|
-
import favicon from "serve-favicon";
|
|
5
|
-
import fs from "fs";
|
|
6
|
-
import { __package } from "../../index.js";
|
|
7
|
-
import insecure from "./insecure.js";
|
|
8
|
-
import requestMethods from "./requestMethods.js";
|
|
9
|
-
import bodyParser from "./bodyParser.js";
|
|
10
|
-
import cors from "./cors.js";
|
|
11
|
-
import render from "./render.js";
|
|
12
|
-
import generateErrorPage from "../../lib/generateErrorPage.js";
|
|
13
|
-
import hasLoginTokenExpired from "../accounts/hasLoginTokenExpired.js";
|
|
14
|
-
import runUserQuery from "../accounts/runUserQuery.js";
|
|
15
|
-
import replaceBackslashesWithForwardSlashes from "../../lib/replaceBackslashesWithForwardSlashes.js";
|
|
16
|
-
import replaceFileProtocol from "../../lib/replaceFileProtocol.js";
|
|
17
|
-
import getBuildPath from "../../lib/getBuildPath.js";
|
|
18
|
-
import session from "./session.js";
|
|
19
|
-
import csp from "./csp.js";
|
|
20
|
-
const cwd = replaceFileProtocol(replaceBackslashesWithForwardSlashes(process.cwd()));
|
|
21
|
-
const faviconPath = "public/favicon.ico";
|
|
22
|
-
var middleware_default = ({
|
|
23
|
-
app,
|
|
24
|
-
port,
|
|
25
|
-
middlewareConfig,
|
|
26
|
-
appInstance,
|
|
27
|
-
cspConfig
|
|
28
|
-
}) => {
|
|
29
|
-
if (process.env.NODE_ENV === "production") {
|
|
30
|
-
app.use(insecure);
|
|
31
|
-
}
|
|
32
|
-
const buildPath = getBuildPath();
|
|
33
|
-
app.use((_req, res, next) => {
|
|
34
|
-
if (process.BUILD_ERROR) {
|
|
35
|
-
const error = process.BUILD_ERROR.paths && process.BUILD_ERROR.paths[0];
|
|
36
|
-
return res.send(generateErrorPage({
|
|
37
|
-
path: error.path,
|
|
38
|
-
stack: error.error.stack,
|
|
39
|
-
frame: error.error.snippet
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
next();
|
|
43
|
-
});
|
|
44
|
-
app.use(requestMethods);
|
|
45
|
-
if (cspConfig) {
|
|
46
|
-
app.use((req, res, next) => csp(req, res, next, cspConfig));
|
|
47
|
-
}
|
|
48
|
-
app.use(compression());
|
|
49
|
-
app.use("/css", express.static("css", { eTag: false, maxAge: "0" }));
|
|
50
|
-
app.use(express.static("public", { eTag: false, maxAge: "0" }));
|
|
51
|
-
app.use("/_joystick/heartbeat", (_req, res) => {
|
|
52
|
-
res.status(200).send("<3");
|
|
53
|
-
});
|
|
54
|
-
app.use("/_joystick/utils/process.js", (_req, res) => {
|
|
55
|
-
res.set("Content-Type", "text/javascript");
|
|
56
|
-
const processPolyfill = fs.readFileSync(`${__package}/app/utils/process.js`, "utf-8");
|
|
57
|
-
res.send(processPolyfill.replace("${NODE_ENV}", process.env.NODE_ENV));
|
|
58
|
-
});
|
|
59
|
-
app.use("/_joystick/index.client.js", express.static(`${buildPath}index.client.js`, {
|
|
60
|
-
eTag: false,
|
|
61
|
-
maxAge: "0"
|
|
62
|
-
}));
|
|
63
|
-
app.use("/_joystick/index.css", express.static(`${buildPath}index.css`, { eTag: false, maxAge: "0" }));
|
|
64
|
-
app.use("/_joystick/ui", express.static(`${buildPath}ui`, { eTag: false, maxAge: "0" }));
|
|
65
|
-
app.use("/_joystick/hmr/client.js", (_req, res) => {
|
|
66
|
-
res.set("Content-Type", "text/javascript");
|
|
67
|
-
const hmrClient = fs.readFileSync(`${__package}/app/middleware/hmr/client.js`, "utf-8");
|
|
68
|
-
res.send(hmrClient.replace("${process.env.PORT}", parseInt(process.env.PORT, 10) + 1));
|
|
69
|
-
});
|
|
70
|
-
app.use(favicon(faviconPath));
|
|
71
|
-
app.use(cookieParser());
|
|
72
|
-
app.use(bodyParser(middlewareConfig?.bodyParser));
|
|
73
|
-
app.use(cors(middlewareConfig?.cors, port));
|
|
74
|
-
app.use((req, res, next) => session(req, res, next, appInstance));
|
|
75
|
-
app.use(async (req, res, next) => {
|
|
76
|
-
const loginTokenHasExpired = await hasLoginTokenExpired(res, req?.cookies?.joystickLoginToken, req?.cookies?.joystickLoginTokenExpiresAt);
|
|
77
|
-
req.context = {
|
|
78
|
-
...req?.context || {},
|
|
79
|
-
user: !loginTokenHasExpired && await runUserQuery("userWithLoginToken", {
|
|
80
|
-
token: req?.cookies?.joystickLoginToken
|
|
81
|
-
}) || null
|
|
82
|
-
};
|
|
83
|
-
next();
|
|
84
|
-
});
|
|
85
|
-
app.use((req, res, next) => render(req, res, next, appInstance));
|
|
86
|
-
};
|
|
87
|
-
export {
|
|
88
|
-
middleware_default as default
|
|
89
|
-
};
|