This is my implementation of a given task by the company I will refer to as YNA.
For a simple version please refer to another branch
NB: I tend to write less unless I'm hyperfocused or feel the need to prove something.
Node.js(see.nvmrcfor the required version)npmTypeScriptnvm(makes life easier but optional)jq(optional)
-
Clone the repository (you may use
--depth=1for a shallow clone):git clone https://github.com/alu-al1/yna_task.git
-
Navigate to the project directory:
cd yna_task -
Install dependencies:
npm install # or use `npm ci` if applicable
You can build different parts of the project with the following scripts:
npm run build– build everythingnpm run build_server– build only the server partnpm run build_client– build only the client partnpm run clean– remove all build artifacts
E(x)tended variants of some scripts are also available. For example, npm run xbuild_server leverages TypeScript config parsing and jq for selecting the actual build directory from tsconfig.json.
For more details, refer to the scripts section in package.json.
To run the server and client with the task provided presets:
npm run build_server && npm WSS_PORT=<available_port> run servernpm run build_client && npm WSS_URL=<url_to_server> run clientℹ️ Both server and client will provide you with
USAGE:message if something is missing.
Both server.ts and client.ts include Node's variant of if __name__ == "__main__" and can be imported and reused with custom presets.
Jest is used for testing.
To run all tests:
npm run clean_tests && npm run build_tests && npm run testsTo test client-server intercommunication with tailored presets:
npm run clean_tests && npm run build_tests && npm run test_one
⚠️ Tests cover various time-based scenarios and will take approximately 17 seconds to complete. Most tests are run in parallel. Refer to the test file(s) for additional environment variable configurations.