This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
refactor(deps): remove ip for node native implementation #1302
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4dfac48
refactor(deps): remove ip for node native implementation
dogpatch626 1d1fa6b
chore(dep): add getIp to franks
dogpatch626 c61763d
chore(dep): fix improper path
dogpatch626 5c0183a
chore(dep): address comment
dogpatch626 2d98150
chore(dep): address comment
dogpatch626 385f4c2
chore(dep): update test
dogpatch626 5a48dd6
chore(dep): update franks
dogpatch626 17f05e4
Merge branch 'main' into chore/replace-ip
dogpatch626 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2023 American Express Travel Related Services Company, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express | ||
* or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import os from 'os'; | ||
import { getIp } from '../../../src/server/utils/getIP'; | ||
|
||
const spy = jest.spyOn(os, 'networkInterfaces'); | ||
|
||
describe('getIp', () => { | ||
it('returns a valid IP address', () => { | ||
spy.mockReturnValue({ | ||
addresses: [ | ||
{ | ||
address: '1.1.1.1', | ||
family: 'IPv4', | ||
internal: true, | ||
}, | ||
{ | ||
address: '2.2.2.2', | ||
family: 'IPv4', | ||
internal: false, | ||
}, | ||
{ | ||
address: '3.3.3.3', | ||
family: 'IPv6', | ||
internal: false, | ||
}, | ||
], | ||
}); | ||
expect(getIp()).toBe('2.2.2.2'); | ||
}); | ||
it('returns 0.0.0.0 if no addresses found', () => { | ||
spy.mockReturnValue({ | ||
addresses: [], | ||
}); | ||
expect(getIp()).toBe('0.0.0.0'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
prod-sample/sample-modules/frank-lloyd-root/0.0.0/src/getIP.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { networkInterfaces } from 'os'; | ||
|
||
export const getIp = () => { | ||
const interfaces = networkInterfaces(); | ||
|
||
const ipAddress = Object.keys(interfaces) | ||
.map((name) => interfaces[name].find((iface) => iface.family === 'IPv4' | ||
&& !iface.internal && iface.address !== '127.0.0.1')) | ||
.filter(Boolean); | ||
|
||
return ipAddress[0] ? ipAddress[0].address : '0.0.0.0'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
prod-sample/sample-modules/frank-lloyd-root/0.0.1/src/getIP.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { networkInterfaces } from 'os'; | ||
|
||
export const getIp = () => { | ||
const interfaces = networkInterfaces(); | ||
|
||
const ipAddress = Object.keys(interfaces) | ||
.map((name) => interfaces[name].find((iface) => iface.family === 'IPv4' | ||
&& !iface.internal && iface.address !== '127.0.0.1')) | ||
.filter(Boolean); | ||
|
||
return ipAddress[0] ? ipAddress[0].address : '0.0.0.0'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
prod-sample/sample-modules/frank-lloyd-root/0.0.2/src/getIP.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { networkInterfaces } from 'os'; | ||
|
||
export const getIp = () => { | ||
const interfaces = networkInterfaces(); | ||
|
||
const ipAddress = Object.keys(interfaces) | ||
.map((name) => interfaces[name].find((iface) => iface.family === 'IPv4' | ||
&& !iface.internal && iface.address !== '127.0.0.1')) | ||
.filter(Boolean); | ||
|
||
return ipAddress[0] ? ipAddress[0].address : '0.0.0.0'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
prod-sample/sample-modules/frank-lloyd-root/0.0.3/src/getIP.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { networkInterfaces } from 'os'; | ||
|
||
export const getIp = () => { | ||
const interfaces = networkInterfaces(); | ||
|
||
const ipAddress = Object.keys(interfaces) | ||
.map((name) => interfaces[name].find((iface) => iface.family === 'IPv4' | ||
&& !iface.internal && iface.address !== '127.0.0.1')) | ||
.filter(Boolean); | ||
|
||
return ipAddress[0] ? ipAddress[0].address : '0.0.0.0'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { networkInterfaces } from 'os'; | ||
|
||
export const getIp = () => { | ||
const interfaces = networkInterfaces(); | ||
|
||
const ipAddress = Object.keys(interfaces) | ||
dogpatch626 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.map((name) => interfaces[name].find((iface) => iface.family === 'IPv4' | ||
&& !iface.internal && iface.address !== '127.0.0.1')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not a blocker but |
||
.filter(Boolean); | ||
|
||
return ipAddress[0] ? ipAddress[0].address : '0.0.0.0'; | ||
dogpatch626 marked this conversation as resolved.
Show resolved
Hide resolved
giulianok marked this conversation as resolved.
Show resolved
Hide resolved
dogpatch626 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
ip
is actually astring
but we return a function, should we return the function call?