-
Notifications
You must be signed in to change notification settings - Fork 541
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
Expose Connector in the public API #906
Conversation
Codecov Report
@@ Coverage Diff @@
## main #906 +/- ##
=======================================
Coverage 99.57% 99.57%
=======================================
Files 26 26
Lines 2132 2132
=======================================
Hits 2123 2123
Misses 9 9
Continue to review full report at Codecov.
|
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.
Actually isn't it better to just expose the factory method instead of the class? The class is just an implementation detail.
I like exposing the class, most of the time the user will just need to initialize it, but if needed it can be extended quite easily. |
But it being a class doesn't really do anything? Nothing is exposed. It's just a silly way to implement a closure. |
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.
I'd prefer a function but I guess a class is fine...
Hold on before merging, there might be an issue with the types, checking... |
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.
Is there a reason why we have a class in the first place? I would just remove it and expose a function.
Nothing other than convenience of implementation. |
Oks, this pr is good to go from my point of view, the types are now correct. |
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.
Awesome work! Could you add docs?
}) | ||
|
||
function getIssuerCertificate (socket) { | ||
let certificate = socket.getPeerCertificate(true) |
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.
Should probably check that socket is a tls.Socket
.
@@ -20,6 +21,7 @@ module.exports.Client = Client | |||
module.exports.Pool = Pool | |||
module.exports.Agent = Agent | |||
|
|||
module.exports.buildConnector = buildConnector |
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.
Now I see why you preferred a class 😄 . Not all that happy with the name but can't think of anything better atm.
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.
lgtm
Docs! ;) |
Ready to go! |
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.
lgtm
* Expose Connector in the public API * Updated test * Add ca fingerprint example * Improve types * Updated test * Nit * Make connector a function instead of a class * Updated test * Updated examples * Updated docs * Updated docs
As titled. I've also added an example to show how to validate the CA fingerprint.
Related: #904 #905