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

fix: remove node-ip dependency #13877

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -21625,7 +21624,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
Loading