Skip to content

DOCSP-32718: add CodeWhisperer comments to SOCKS5 code snippet #765

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions source/code-snippets/connection/socks.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
import { MongoClient } from "mongodb";

// start-socks
// Replace the placeholder with your connection string
const uri = "<connection string uri>";

// Replace the placeholders with your SOCKS5 proxy server details
const socksOptions = {
proxyHost: "<host>",
proxyPort: 1080,
proxyUsername: "<username>",
proxyPassword: "<password>",
};

// Create a new client with the proxy server details
const client = new MongoClient(uri, socksOptions);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Add a comment above this specifying that it is connecting and passing in the socksOptions

// end-socks

// Retrieve the first document from the MongoDB collection and print it
async function run() {
try {
const db = client.db("myDB");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Add a comment on the await client.close() section (line 25, can't reach it with a PR comment) stating that it is closing the client when complete. This is to match similar comments in other files

const myColl = db.collection("myColl");
const doc = await myColl.findOne({});
console.log(doc);
} finally {
// Close the connection after the operation completes
await client.close();
}
}
Expand Down