{"id":17789992,"url":"https://github.com/samrocksc/simple-api","last_synced_at":"2025-06-26T12:05:33.770Z","repository":{"id":69548389,"uuid":"578547123","full_name":"samrocksc/simple-api","owner":"samrocksc","description":"API Pass Through Application","archived":false,"fork":false,"pushed_at":"2022-12-20T11:24:03.000Z","size":149,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T16:56:22.069Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/samrocksc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-12-15T10:10:28.000Z","updated_at":"2022-12-18T11:57:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"eb07c160-9d38-461c-82a8-046519cb3c71","html_url":"https://github.com/samrocksc/simple-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samrocksc%2Fsimple-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samrocksc%2Fsimple-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samrocksc%2Fsimple-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samrocksc%2Fsimple-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samrocksc","download_url":"https://codeload.github.com/samrocksc/simple-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246735323,"owners_count":20825223,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-10-27T10:39:39.109Z","updated_at":"2025-04-02T01:16:57.149Z","avatar_url":"https://github.com/samrocksc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-api\n\n## Install/Start\n\n- `npm i`\n- `npm run start`\n- `curl localhost:3000/users-transactions/1`\n- `curl localhost:3000/users-relations/2`\n\nAPI Pass Through Application\n\nThere's clear room for improvement on this, but due to the fact that we're using a JSON format to build our relations, the best way would be to build something like a balanced-tree so you could easily check with object destructuring.\n\nI opted for a bit of a more functional approach(most functions can easily b e curried, or encapsulate eachother).  Primarily I wanted to show a solid understanding of testing, types, and understanding of neeeds.\n\nI think it would be easier to build junction tables(you could even do it with noSQL), and then hydrate junction tables as transactions accrue so you could easily build modeling from meta data of an event than direct data comparison of the entire object.\n\nAlternatively, you could build a caching layer with Elastic or something of that nature on top of this to help identify these events if time was less of a factor\n\n\n## Steps I Took In Development\n\n1. I inited the project with basic typescript and my preference of ESLint rules that help with readonly typing and prevent mutability.\n2. I first hit the sample endpoint, and copied and pasted the JSON response into https://quicktype.io and generated Typescript types.  I also converted these into readonly types instead of interfaces to create a rock solid typing base to extend from.\n3. I created `aggregateById.test.ts` first in order to put in the test requirements for the application\n4. I installed Jest, as it's the most commonly used library for almost every company I've worked with in the past 5 years.\n5. I created a simple fetch request to retrieve the data from the api endpoint and checked it against types to make sure all's good!\n6. After I checked the API endpoint, I built the mapRelatedTransactions.  I was able to re-use functions from previous calls\n7. I added a query function by deviceId.\n\n## Development decisions\n\n- because the criteria for this test was tests, I wrote this test in TDD writing my expectations first\n- I wrote this application as a ladder, so that each previous step would build into the next step.\n- I tried to follow the philosophy of \"Do one thing and do it well\" which resulted in using extremely specific mapping functions, instead of the DRY philosophy, being able to test every section was important there.\n- I started kind of running out of time, so I declined on turning `deviceRelation` and `transactionRelation` into their own functions.\n\n## Fraud identifications\n\nI did notice that the deviceId `F210200` had multiple customerId's utilizing it which I do believe indicates there may ahve been fraud\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamrocksc%2Fsimple-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamrocksc%2Fsimple-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamrocksc%2Fsimple-api/lists"}