Skip to content

Commit

Permalink
fix: remove node-ip dependency (#13877)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilson-anonyome authored Aug 12, 2024
1 parent 054efa5 commit 5e9cd5e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 0 additions & 1 deletion packages/amplify-appsync-simulator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"graphql": "^15.5.0",
"graphql-iso-date": "^3.6.1",
"graphql-subscriptions": "^1.1.0",
"ip": "^1.1.9",
"js-string-escape": "^1.0.1",
"jwt-decode": "^2.2.0",
"libphonenumber-js": "1.9.47",
Expand Down
13 changes: 12 additions & 1 deletion packages/amplify-appsync-simulator/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@ import { Server, createServer } from 'http';
import { createServer as createHttpsServer } from 'https';
import { readFileSync } from 'fs';
import { fromEvent } from 'promise-toolbox';
import { address as getLocalIpAddress } from 'ip';
import { AppSyncSimulatorSubscriptionServer } from './websocket-subscription';
import getPort from 'get-port';
import { REALTIME_SUBSCRIPTION_PATH } from './subscription/websocket-server/server';
import os from 'os';

const BASE_PORT = 8900;
const MAX_PORT = 9999;

function getLocalIpAddress(): string {
const interfaces = os.networkInterfaces();
const internalAddresses = Object.keys(interfaces)
.map((nic) => {
const addresses = interfaces[nic].filter((details) => details.internal);
return addresses.length ? addresses[0].address : undefined;
})
.filter(Boolean);
return internalAddresses.length ? internalAddresses[0] : '127.0.0.1';
}

export class AppSyncSimulatorServer {
private _operationServer: OperationServer;
private _httpServer: Server;
Expand Down
3 changes: 1 addition & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ __metadata:
graphql: ^15.5.0
graphql-iso-date: ^3.6.1
graphql-subscriptions: ^1.1.0
ip: ^1.1.9
jose: ^5.2.0
js-string-escape: ^1.0.1
jwt-decode: ^2.2.0
Expand Down Expand Up @@ -21603,7 +21602,7 @@ __metadata:
languageName: node
linkType: hard

"ip@npm:^1.1.8, ip@npm:^1.1.9":
"ip@npm:^1.1.8":
version: 1.1.9
resolution: "ip@npm:1.1.9"
checksum: 5af58bfe2110c9978acfd77a2ffcdf9d33a6ce1c72f49edbaf16958f7a8eb979b5163e43bb18938caf3aaa55cdacde4e470874c58ca3b4b112ea7a30461a0c27
Expand Down

0 comments on commit 5e9cd5e

Please sign in to comment.