-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
MongoDB connector now includes SOCKS5 proxy settings #11731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
feat(mongodb): add Socks5 proxy configuration options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds SOCKS5 proxy configuration support to the MongoDB driver, enabling TypeORM users to connect to MongoDB through a SOCKS5 proxy server.
Key Changes:
- Added four new connection options for SOCKS5 proxy configuration:
proxyHost,proxyPort,proxyUsername, andproxyPassword - Updated the MongoDB driver to recognize and pass through these proxy options to the underlying MongoDB client
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/driver/mongodb/MongoConnectionOptions.ts | Defines the new SOCKS5 proxy configuration options as part of the MongoDB connection interface |
| src/driver/mongodb/MongoDriver.ts | Registers the new proxy options in the allowed MongoDB options list for pass-through to MongoClient |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
WalkthroughAdds four optional Socks5 proxy configuration fields to MongoDB connection options and accepts them in the driver's option validation; adds a test asserting the proxy fields are forwarded to MongoClient.connect. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Test
participant Driver as MongoDriver
participant Client as MongoClient.connect
Test->>Driver: create driver with options { ..., proxyHost, proxyPort, proxyUsername, proxyPassword }
Test->>Client: (fake) replace MongoClient.connect -> Promise.resolve()
Driver->>Client: connect(uri, options)
note right of Client #E8F3FF: options include proxyHost,\nproxyPort, proxyUsername, proxyPassword
Client-->>Driver: Promise resolves
Driver-->>Test: connect() resolves
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
gioboa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask you to add a test to validate these new settings?
|
@gioboa i am fine with adding tests. But one small problem. I wasn't able to find any tests for mongodb at all? Do you want me to add them as well? |
|
@gioboa added test cases. Weren't able to test them locally due to better-sqlite3 build issues on my machine. is there any active work on updating it or moving away from it? I saw some issues pointing to move away from it? Will wait for CI test runners, to see if all fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
test/functional/driver/MongoDriver.ts (1)
62-98: Test correctly verifies proxy options are passed to MongoClient.The test properly mocks
MongoClient.connect, callsdriver.connect(), and asserts that all four proxy configuration fields are present in the options passed to the underlying MongoDB driver. The use ofsinon.fake.resolves({})is appropriate for this async mock.Consider adding edge-case tests to improve coverage:
- Test with partial proxy configuration (e.g., only
proxyHostandproxyPort)- Test that proxy options coexist correctly with other MongoDB connection options
- Test behavior with missing optional proxy credentials (
proxyUsername,proxyPassword)These additions would strengthen the test suite but are not critical for the current implementation.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
test/functional/driver/MongoDriver.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
test/functional/driver/MongoDriver.ts (1)
src/driver/mongodb/MongoDriver.ts (2)
MongoDriver(32-575)connect(246-258)
gioboa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Kumar-Kishan for your help 👍
Description of change
Add socks proxy configuration options
Pull-Request Checklist
masterbranch10529Summary by CodeRabbit
New Features
Tests