{"id":49414205,"url":"https://github.com/daemon-node-byte/oneorigin","last_synced_at":"2026-04-29T02:13:44.019Z","repository":{"id":222369873,"uuid":"622081491","full_name":"daemon-node-byte/OneOrigin","owner":"daemon-node-byte","description":"Interview technical assessment","archived":false,"fork":false,"pushed_at":"2023-04-01T19:15:58.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-22T01:34:55.802Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daemon-node-byte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-01T04:13:14.000Z","updated_at":"2024-07-22T01:35:12.416Z","dependencies_parsed_at":null,"dependency_job_id":"6ae0dd29-26ec-4955-9a24-00b22f7ed912","html_url":"https://github.com/daemon-node-byte/OneOrigin","commit_stats":null,"previous_names":["jmclain-origin/oneorigin","daemon-node-byte/oneorigin"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/daemon-node-byte/OneOrigin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daemon-node-byte%2FOneOrigin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daemon-node-byte%2FOneOrigin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daemon-node-byte%2FOneOrigin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daemon-node-byte%2FOneOrigin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daemon-node-byte","download_url":"https://codeload.github.com/daemon-node-byte/OneOrigin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daemon-node-byte%2FOneOrigin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32407251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"online","status_checked_at":"2026-04-29T02:00:06.602Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-29T02:13:42.166Z","updated_at":"2026-04-29T02:13:44.010Z","avatar_url":"https://github.com/daemon-node-byte.png","language":"TypeScript","readme":"# OneOrigin\n\nInterview technical assessment\n\n## Round One\n\nnode script: run command\n\n```bash\nnpm run roundOne\n```\n\n[source code](./refactorRoundOne.ts)\n\n### Issue\n\nMake a 1000 API calls to an endpoint that has a rate limit of 100 requests per 1 minute.\n\n### Solution\n\nCreate a function that will dispatch total required requests with in the restrictions set.\n\n### Code Explanation\n\nMy approach is to break down the steps of the process and build out as if each function is a shared utility to eliminate the overhead of repeated code blocks.\n\n- First create a function (`getRequest`) that makes a single request and returns a response.\n- Next create a function (`batchRequests`) that will make multiple requests.\n- Last create a function (`sendBatch`) that will make interval requests in respect of arguments passed.\n\nThe `getRequest` function uses a predefined domain for our API service (global `API_DOMAIN`) and passing a parameter during call it ping desired endpoint. Here I added a increment to a global variable `REQUESTS_SENT` for verification of action later.\n\nThe `batchRequests` function makes multiple GET requests in a single call, passing a parameter to ping desired endpoint and amount of requests per function call. I choose recursion because of readability and time complexity. May not make much difference at 100 requests per function call, but 1000+ there may be a measurable difference.\n\nThe `sendBatch` function handles the batch of requests made withing various rate limit restrictions. Does take four arguments, The endpoint the batch of requests will be sent to, the max number of requests per batch, and the number of seconds between batches of requests, (thought seconds to be best for use in any testing suites) and last argument for the total number of requests desired. I tried catch edge cases that may had been unaccounted for. Such as the first batch of requests should run with no delay (handled by `initSend ? 0 : delaySeconds * 1000`), or a use case where the max number of requests per batch does't factor in to the total number of requests as a whole number (handle by `maxRatePer \u003e remainingTotal ? remainingTotal : maxRatePer`)\n\nFor the purposes of running in node environment vs web, consoled out running timestamps and assertion if global `REQUESTS_SENT` matches the total number of requests passed as an parameter. Areas for improvement, I think making the functions asynchronous, adding custom resolve/reject handling and returning a `Promise` along with collected response data of batched requests. I think that would be an improvement and much more reliable and easier for debugging.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaemon-node-byte%2Foneorigin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaemon-node-byte%2Foneorigin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaemon-node-byte%2Foneorigin/lists"}