Skip to content

Commit 5e9cd5e

Browse files
fix: remove node-ip dependency (#13877)
1 parent 054efa5 commit 5e9cd5e

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

packages/amplify-appsync-simulator/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"graphql": "^15.5.0",
4545
"graphql-iso-date": "^3.6.1",
4646
"graphql-subscriptions": "^1.1.0",
47-
"ip": "^1.1.9",
4847
"js-string-escape": "^1.0.1",
4948
"jwt-decode": "^2.2.0",
5049
"libphonenumber-js": "1.9.47",

packages/amplify-appsync-simulator/src/server/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,25 @@ import { Server, createServer } from 'http';
55
import { createServer as createHttpsServer } from 'https';
66
import { readFileSync } from 'fs';
77
import { fromEvent } from 'promise-toolbox';
8-
import { address as getLocalIpAddress } from 'ip';
98
import { AppSyncSimulatorSubscriptionServer } from './websocket-subscription';
109
import getPort from 'get-port';
1110
import { REALTIME_SUBSCRIPTION_PATH } from './subscription/websocket-server/server';
11+
import os from 'os';
1212

1313
const BASE_PORT = 8900;
1414
const MAX_PORT = 9999;
1515

16+
function getLocalIpAddress(): string {
17+
const interfaces = os.networkInterfaces();
18+
const internalAddresses = Object.keys(interfaces)
19+
.map((nic) => {
20+
const addresses = interfaces[nic].filter((details) => details.internal);
21+
return addresses.length ? addresses[0].address : undefined;
22+
})
23+
.filter(Boolean);
24+
return internalAddresses.length ? internalAddresses[0] : '127.0.0.1';
25+
}
26+
1627
export class AppSyncSimulatorServer {
1728
private _operationServer: OperationServer;
1829
private _httpServer: Server;

yarn.lock

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ __metadata:
123123
graphql: ^15.5.0
124124
graphql-iso-date: ^3.6.1
125125
graphql-subscriptions: ^1.1.0
126-
ip: ^1.1.9
127126
jose: ^5.2.0
128127
js-string-escape: ^1.0.1
129128
jwt-decode: ^2.2.0
@@ -21603,7 +21602,7 @@ __metadata:
2160321602
languageName: node
2160421603
linkType: hard
2160521604

21606-
"ip@npm:^1.1.8, ip@npm:^1.1.9":
21605+
"ip@npm:^1.1.8":
2160721606
version: 1.1.9
2160821607
resolution: "ip@npm:1.1.9"
2160921608
checksum: 5af58bfe2110c9978acfd77a2ffcdf9d33a6ce1c72f49edbaf16958f7a8eb979b5163e43bb18938caf3aaa55cdacde4e470874c58ca3b4b112ea7a30461a0c27

0 commit comments

Comments
 (0)