ngrok icon indicating copy to clipboard operation
ngrok copied to clipboard

Improvements for getApi()

Open Collin-St opened this issue 2 years ago • 0 comments

Solution for #252

Changes

index.js - getApi()

  • Check if ngrokClient is defined, return if so. Else, Call getProcessUrl to get the process URL for port 4040, and create a new instance of NgrokClient. Fallback to null.

src/process.js

  • Include getProcessUrl which spawns a child process and makes the platform appropriate query for port 4040's process URL.

ngrok.d.ts

  • Update getApi() type definition to return a nullable promise.

test/ngrok.guest.spec.js

  • Update "getting internal api wrapper" test case to call getApi() with async/await.
  • Include additional assertion "should be an instance of NgrokClient" .

Tests run successfully on Mac, Windows 10, and Linux. Open to any improvements!

Collin-St avatar Oct 15 '21 04:10 Collin-St