diff --git a/Jenkinsfile b/Jenkinsfile index 81d532c..12d359d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,7 @@ pipeline { VERSION = VersionNumber([ versionNumberString: '${BUILDS_ALL_TIME}', - versionPrefix: '1.0.', + versionPrefix: '1.1.', worstResultForIncrement: 'SUCCESS' ]) } diff --git a/http_status_codes.js b/http_status_codes.js new file mode 100644 index 0000000..ec4724d --- /dev/null +++ b/http_status_codes.js @@ -0,0 +1,141 @@ +/* eslint-disable no-magic-numbers */ +/* eslint-disable sort-keys */ + +'use strict'; + +const status_codes = { + + /* INFORMATIONAL */ + status_continue: 100, + status_switching_protocols: 101, + status_processing: 102, + status_early_hints: 103, + + /* SUCCESS */ + status_ok: 200, + status_created: 201, + status_accepted: 202, + status_non_authoritative: 203, + status_no_content: 204, + + // backwards compatibility with consts 1.0 + status_ok_no_content: 204, + status_reset_content: 205, + status_partial_content: 206, + status_multi_status: 207, + status_already_reported: 208, + status_im_used: 226, + + /* REDIRECT */ + status_multiple_choices: 300, + status_moved_permanently: 301, + status_found: 302, + status_see_other: 303, + status_not_modified: 304, + status_use_proxy: 305, + status_switch_proxy: 306, + status_temporary_redirect: 307, + status_permanent_redirect: 308, + + /* CLIENT ERROR */ + status_bad_request: 400, + status_unauthorized: 401, + status_payment_required: 402, + status_forbidden: 403, + status_not_found: 404, + status_method_not_allowed: 405, + status_not_acceptable: 406, + status_proxy_authentication_required: 407, + status_request_timeout: 408, + status_conflict: 409, + status_gone: 410, + status_length_required: 411, + status_precondition_failed: 412, + status_payload_too_large: 413, + status_uri_too_long: 414, + status_unsupported_media_type: 415, + status_range_not_satisfiable: 416, + status_expectation_failed: 417, + status_im_a_teapot: 418, + status_misdirected_request: 421, + status_unprocessable_entity: 422, + status_locked: 423, + status_failed_dependency: 424, + status_too_early: 425, + status_upgrade_required: 426, + status_precondition_required: 428, + status_too_many_requests: 429, + status_request_header_fields_too_large: 431, + status_unavailable_for_legal_reasons: 451, + + /* SERVER ERROR */ + status_internal_server_error: 500, + status_not_implemented: 501, + status_bad_gateway: 502, + status_service_unavailable: 503, + status_gateway_timeout: 504, + status_http_version_not_supported: 505, + status_variant_also_negotiates: 506, + status_insufficient_storage: 507, + status_loop_detected: 508, + status_not_extended: 510, + status_network_authentication_required: 511 +}; + +const unofficial = { + status_checkpoint: 103, + status_this_is_fine: 218, + status_page_expired: 419, + status_method_failure: 420, + status_enhance_your_calm: 420, + status_request_header_fields_too_large: 430, + status_blocked_by_windows_parental_controls: 450, + status_invalid_token: 498, + status_token_expired: 499, + status_bandwidth_limit_exceeded: 509, + status_invalid_ssl_certificate: 526, + status_site_is_overloaded: 529, + status_site_is_frozen: 530, + status_network_read_timeout_error: 598 +}; + +const iis = { + status_login_timeout: 440, + status_retry_with: 449, + status_redirect: 451 +}; + +const nginx = { + status_no_response: 444, + status_request_header_too_large: 494, + status_ssl_certificate_error: 495, + status_ssl_certificate_required: 496, + status_http_request_sent_to_https_port: 497, + status_client_closed_request: 499 +}; + +const cloudflare = { + status_web_server_returned_unknown_error: 520, + status_web_server_is_down: 521, + status_connection_timed_out: 522, + status_origin_is_unreachable: 523, + status_a_timeout_occured: 524, + status_ssl_handshake_failed: 525, + status_invalid_ssl_certificate: 526, + status_railgun_error: 527, + status_530: 530 +}; + +const aws_loadbalance = { + status_client_closed_connection: 460, + status_too_many_adresses: 463 +}; + +module.exports = { + status_codes, + unofficial, + iis, + nginx, + cloudflare, + aws_loadbalance +}; diff --git a/index.js b/index.js index b42d015..6c2e5ef 100644 --- a/index.js +++ b/index.js @@ -5,17 +5,15 @@ * Created by Timo Hocker , March 2020 */ -/* eslint-disable no-magic-numbers */ 'use strict'; +const http = require ('./http_status_codes'); + module.exports = { http: { - status_ok: 200, - status_ok_no_content: 204, - status_bad_request: 400, - status_unauthorized: 401, - status_forbidden: 403, - status_not_found: 404 + ...http.status_codes, + ...http } }; + diff --git a/package.json b/package.json index 8bc54b6..6471d7e 100644 --- a/package.json +++ b/package.json @@ -12,5 +12,8 @@ "lint": "eslint .", "test": "echo \"no test\"", "ci": "yarn && node jenkins.js" + }, + "engines": { + "node": ">=10.0.0" } }