Skip to content

Conversation

@JacobLinCool
Copy link
Owner

This pull request introduces significant updates to the cloudflared library, including the addition of new classes for handling tunnel events, updates to example files, and modifications to the test suite. The most important changes are the introduction of the Tunnel class with enhanced event handling capabilities, updates to the example files to utilize the new Tunnel class, and modifications to the test suite to accommodate these changes.

Major Updates to Tunnel Handling:

  • src/tunnel.ts: Introduced the Tunnel class, which extends EventEmitter and includes methods for handling tunnel events such as url, connected, disconnected, stdout, stderr, error, and exit. Added static methods quick and withToken for creating tunnels with or without a Cloudflare account.

Example Files Updates:

  • examples/tunnel.js, examples/tunnel.mjs: Updated to use the new Tunnel class instead of the previous tunnel function. This change simplifies the code and leverages the new event handling capabilities of the Tunnel class. [1] [2]
  • examples/events.mjs: Added a new example file demonstrating how to use the Tunnel class and handle various events such as url, connected, disconnected, stdout, stderr, exit, and error.

Test Suite Modifications:

  • src/_tests/index.test.ts: Updated the test suite to use the new Tunnel class instead of the previous tunnel function. Added a timeout configuration to the describe blocks to ensure tests complete within a reasonable time frame. [1] [2] [3]

Additional Enhancements:

  • src/handler.ts: Added new classes ConnectionHandler, TryCloudflareHandler, and ConfigHandler to handle specific tunnel events and configurations. These classes are used internally by the Tunnel class to process output and emit relevant events.
  • src/lib.ts: Updated exports to include the new Tunnel class and related handlers, ensuring they are available for use in other parts of the application.

Documentation Updates:

  • README.md: Updated the example code to use the new Tunnel class, demonstrating its usage and event handling capabilities. [1] [2]

These changes collectively improve the flexibility and functionality of the cloudflared library, making it easier to create and manage tunnels with enhanced event handling capabilities.

@JacobLinCool JacobLinCool requested a review from Copilot December 11, 2024 18:11
@JacobLinCool JacobLinCool self-assigned this Dec 11, 2024
@changeset-bot
Copy link

changeset-bot bot commented Dec 11, 2024

🦋 Changeset detected

Latest commit: 063c96f

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 10 changed files in this pull request and generated no suggestions.

Files not reviewed (5)
  • .changeset/tall-gorillas-taste.md: Evaluated as low risk
  • .github/workflows/test.yml: Evaluated as low risk
  • README.md: Evaluated as low risk
  • examples/events.mjs: Evaluated as low risk
  • examples/tunnel.js: Evaluated as low risk

@JacobLinCool JacobLinCool merged commit 8d5fb54 into main Dec 11, 2024
15 checks passed
@github-actions github-actions bot mentioned this pull request Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants