Closed hiyaryan closed 2 months ago
Note that these changes allows the development container to be up. In other words, the development container may be running simultaneously with the test environment because it runs on a different port.
@davidzlu Per your review I have reverted to pre-yargs
code and wrote a new utility function to dynamically assign a port based on the PORT
in .env
called getPort
. It does this by incrementing the port by 1 with checks to ensure that the port is available to use using a isPortInUse
in the same util file. With that I updated index.ts
and it's associated test file to use the getPort
function. And I added unit tests for getPort
.
What's good about having this function is that we no longer require additional dependencies, it feels like a better or less "dirty" solution than using hardcoded port values, and we can also further enhance the code for convenience to check that the PORT
in .env is available in the development environment in a future PR if we're keen.
Great update @davidzlu! 🙌 An elegant and simple solution. I pushed a followup commit that just completely removes the getPort
utility function (-1 for the utils
directory). Somewhat of a revert with a little refactoring and code clean up.
Removes MEMORY environment variable. Uses yargs to pass arguments to the application on launch.