{"id":49583592,"url":"https://github.com/devtorello/bexchange","last_synced_at":"2026-05-03T21:36:34.915Z","repository":{"id":52497038,"uuid":"520622657","full_name":"devtorello/bexchange","owner":"devtorello","description":"💸  API that should retrieve the best exchange value between three different sources using Deno, Oak, Redis and Fetch API.","archived":false,"fork":false,"pushed_at":"2022-08-03T18:03:59.000Z","size":9,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-05-03T21:36:01.324Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devtorello.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}},"created_at":"2022-08-02T19:19:40.000Z","updated_at":"2024-12-11T12:23:06.000Z","dependencies_parsed_at":"2022-08-13T02:00:55.910Z","dependency_job_id":null,"html_url":"https://github.com/devtorello/bexchange","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devtorello/bexchange","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtorello%2Fbexchange","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtorello%2Fbexchange/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtorello%2Fbexchange/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtorello%2Fbexchange/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devtorello","download_url":"https://codeload.github.com/devtorello/bexchange/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtorello%2Fbexchange/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32586187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-05-03T21:36:34.389Z","updated_at":"2026-05-03T21:36:34.905Z","avatar_url":"https://github.com/devtorello.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 💸 Bexchange\n\nThis is an API that should retrieve the best exchange value between three different sources. Each source behaves in a\ndifferent manner:\n\n- Service A: a normal API that should return the exchange value immediately;\n- Service B: a delayed API that should return the exchange value a few seconds after the request;\n- Service C: an asynchronous API that should deliver the exchange value to a callback.\n\nThe idea behind the implementation is to wait for all of the responses before returning anything to the requester/user.\nThe trick here was to get the response from the callback in runtime - not waiting for the callback response for more\nthan five seconds.\n\nThis challenge was based on [Zanfranceschi's article](https://dev.to/zanfranceschi/desafio-integracao-com-apis-4jco).\nYou can find more information about it there.\n\n## 🔍 The approach\n\nIn order to do the challenge, I've chosen _deno_, _redis_, _oak_ and _fetch_. I always wanted to use deno and I thought\nthat this would be the perfect opportunity to do so and oak seemed as a good option to use when building my APIs. My\ngreatest challenge here was to find how I would retrieve the callback response in runtime.\n\nI tried to look for [ZeroMQ](https://zeromq.org/) or some IPC for deno, but I was not able to find anything reliable.\nWith that being said, I decided to go with Redis, since I could use the `cid` returned field to save the exchange value\nin memory and still would be able to recover it in between the 5 seconds time limit. Probably there is a better way to\nimplement it, but that's what worked for me. :)\n\n## 📝 Files Structure\n\nHere's the explanation about the files from the project:\n\n```\n📦src                   - the folder containing all implementation files.\n ┣ 📜consts.ts          - the file were constants are being stored.\n ┣ 📜deps.ts            - the file were dependencies are declared.\n ┣ 📜exchange.ts        - the file were the logic between exchange requests was made.\n ┣ 📜helpers.ts         - the file were helper methods were created in order to be able to do the actual requests.\n ┣ 📜redis.ts           - the file were redis logic was implemented.\n ┗ 📜server.ts          - the file were the API was created and things were glued together.\n 🧰 configs.json        - the file were the configuration specificities were created.\n 🐋 Dockerfile          - application's dockerization.\n 🐋 docker-compose.yml  - the file containing all necessary containers to run the application.\n```\n\n## ⚙️ How to run?\n\nIn order to run this project, you'll need to execute the following commands:\n\n```bash\ngit clone git@github.com:devtorello/bexchange.git\ncd bexchange\ndocker-compose up --build\n```\n\nKeep in mind that you don't have to have deno installed, but you'll need docker and docker-compose for sure. :)\n\n## 🌐 Endpoints\n\nAfter executing the following commands, you'll have access to the following endpoints:\n\n### Verify if app is running\n\nThis is a endpoint that should exist just for you to check if the application is running already.\n\n```bash\nGET http://localhost:8000\n\ncurl http://localhost:8000 # if you want to execute it from your terminal\n```\n\n### Retrieve Best Exchange\n\nThis is the endpoint that should be supposed to return the best exchange between all services. You can request it\nthrough your browser, curl, insomnia and etc.\n\n```bash\nGET http://localhost:8000/:currency # the currency can be values as USD, EUR, BRL and so on\n\ncurl http://localhost:8000/USD # if you want to execute it from your terminal\n```\n\n## 🤪 Disclaimers\n\nI don't like semicolons **at all**. However, since this is a thing on deno, I kept it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtorello%2Fbexchange","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevtorello%2Fbexchange","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtorello%2Fbexchange/lists"}