Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

♻️ Refactor relay options handling and improve command-line in… #22

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

dansleboby
Copy link

This pull request introduces several enhancements to the relay-server application, mainly focusing on refactoring the code to use a centralized RelayOptions object for configuration, adding new logging features, and improving error handling. Here are the most important changes:

Usage: requestbin --host=<host> --stream=<stream> --target=<target> [options]

Options:
  --host=<host>                Request Bin host (default: ${defaultHost})
  --stream=<stream>              Request Bin stream ID
  --target=<target>            Target URL to relay requests to
  --ignore-ssl-validation          Disable SSL certificate validation
  --verbose-payload            Log request payload
  --verbose-response           Log full response
  --verbose-response-error     Log only response errors
  --help                       Show this help message

Refactoring and Code Simplification:

  • Centralized Configuration: Introduced a RelayOptions interface to centralize configuration options, replacing individual arguments with a single object in cli.ts, relay.ts, and requestBinStream.ts (relay-server/app/cli.ts [1] relay-server/app/relay.ts [2] relay-server/app/requestBinStream.ts [3].
  • Updated Function Signatures: Modified the requestBinStream and relay functions to accept the RelayOptions object instead of multiple parameters (relay-server/app/requestBinStream.ts [1] relay-server/app/relay.ts [2].

Logging Enhancements:

  • Verbose Logging Options: Added new command-line options for verbose logging of payloads, responses, and response errors. These options are now part of the RelayOptions object and are utilized in the relay function for detailed logging (relay-server/app/cli.ts [1] relay-server/app/relay.ts [2].

Error Handling Improvements:

  • SSL Validation Control: Added an option to disable SSL certificate validation, controlled via the ignoreSslValidation flag in the RelayOptions object (relay-server/app/cli.ts relay-server/app/cli.tsR5-R67).
  • Enhanced Error Messages: Improved error messages for missing or invalid arguments and for stream errors, providing clearer feedback to the user (relay-server/app/cli.ts [1] relay-server/app/requestBinStream.ts [2].

These changes collectively improve the maintainability, configurability, and usability of the relay-server application.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant