Skip to content
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

Refactor to ES6 #23

Merged
merged 6 commits into from
Mar 7, 2017
Merged

Refactor to ES6 #23

merged 6 commits into from
Mar 7, 2017

Conversation

fluxsauce
Copy link
Contributor

@fluxsauce fluxsauce commented Mar 6, 2017

Howdy,

As requested in #22 , I've refactored to ES6.

What changed:

  • Added .editorconfig that matches project's existing style - see http://editorconfig.org for details
  • Added ESLint standards (extending airbnb-base)
  • Updated major version to 2.0.0 (ES6 vs the ES5 1.x releases)
  • Switched istanbul for successor, nyc - see https://github.com/istanbuljs/nyc for details
  • Added dependency to is.js, a micro check library for IP and other validation validation

Code coverage is at 84%.

Let me know if you have any questions, comments or concerns, happy to help and discuss!


module.exports = {
getClientIpFromXForwardedFor,
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think we need to export getClientIpFromXForwardedFor. Should be a private method for getClientIp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Keeping as it makes it explicitly testable on its own.

Copy link
Owner

Choose a reason for hiding this comment

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

Makes sense, anything in the name of testabliity 👍

@pbojinov
Copy link
Owner

pbojinov commented Mar 6, 2017

Very nice! Love the added JSDocs and ESLint. I'll review it

Any idea why the coverage dropped from 100% to 85%, just curious?

@fluxsauce
Copy link
Contributor Author

Any idea why the coverage dropped from 100% to 85%, just curious?

It's not making it to the of the block; I removed some logic that made some test-only changes to the headers. A better way would be to just mock it rather than making a request, which I can work on.

@pbojinov
Copy link
Owner

pbojinov commented Mar 6, 2017

That makes sense if its not making it to some of the test only logic.

That'd be really cool to see a mock POC, it would definitely make the tests run much faster.

We could leave the request tests as the integration tests and the mocks could the quick sanity checks.

@fluxsauce
Copy link
Contributor Author

@pbojinov Updated!

test/index.js Outdated
@@ -326,6 +327,56 @@ test('req.connection.socket.remoteAddress', (t) => {
});
});

test('getClientIp - req.connection.remoteAddress', (t) => {
t.plan(1);
const found = requestIp.getClientIp({
Copy link
Owner

Choose a reason for hiding this comment

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

genius!

@pbojinov pbojinov merged commit fcea701 into pbojinov:master Mar 7, 2017
@pbojinov pbojinov mentioned this pull request Mar 7, 2017
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