{"id":15289117,"url":"https://github.com/neandertech/smithy4s-fetch","last_synced_at":"2025-04-13T06:32:09.782Z","repository":{"id":245397702,"uuid":"817382591","full_name":"neandertech/smithy4s-fetch","owner":"neandertech","description":"Smithy4s client directly using Fetch APIs, without bringing http4s/cats, to dramatically reduce bundle size","archived":false,"fork":false,"pushed_at":"2024-07-07T10:35:11.000Z","size":21,"stargazers_count":12,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T23:11:34.191Z","etag":null,"topics":["fetch","scala","scalajs","smithy","smithy4s"],"latest_commit_sha":null,"homepage":"","language":"Scala","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/neandertech.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":"2024-06-19T15:29:55.000Z","updated_at":"2024-09-08T05:26:05.000Z","dependencies_parsed_at":"2024-06-22T00:25:16.810Z","dependency_job_id":"b3b51486-67e8-4de7-8775-f9b7c585fa7e","html_url":"https://github.com/neandertech/smithy4s-fetch","commit_stats":null,"previous_names":["neandertech/smithy4s-fetch"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neandertech%2Fsmithy4s-fetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neandertech%2Fsmithy4s-fetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neandertech%2Fsmithy4s-fetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neandertech%2Fsmithy4s-fetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neandertech","download_url":"https://codeload.github.com/neandertech/smithy4s-fetch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248674660,"owners_count":21143760,"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":["fetch","scala","scalajs","smithy","smithy4s"],"created_at":"2024-09-30T15:59:19.050Z","updated_at":"2025-04-13T06:32:09.479Z","avatar_url":"https://github.com/neandertech.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# smithy4s-fetch\n\n\u003c!--toc:start--\u003e\n- [smithy4s-fetch](#smithy4s-fetch)\n  - [Installation](#installation)\n  - [Getting started](#getting-started)\n  - [Contributing](#contributing)\n  \u003c!--toc:end--\u003e\n\nAn _experimental_ [Smithy4s](https://disneystreaming.github.io/smithy4s/) client backend for [Scala.js](https://www.scala-js.org/), utilising [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) directly, without introducing a http4s/cats dependency.\n\nThe purpose of this library is to provide users of Smithy4s backend services a more lightweight client for the frontend – if your Scala.js frontend is not using Cats/Cats-Effect based libraries, you can communicate with your Smithy4s backend directly using Fetch, **reducing bundle size by as much as 50% in some instances**.\n\nThe library is currently only available for Scala 3, but we will welcome contributions cross-compiling it to 2.13 – it should be very easy. API surface is very minimal and designed for binary compatible evolution, so after initial round of testing and gathering community feedback, we plan to release 1.0.0 and start checking binary/Tasty compatibility for each release.\n\n## Installation\n\nLatest version: [![smithy4s-fetch Scala version support](https://index.scala-lang.org/neandertech/smithy4s-fetch/smithy4s-fetch/latest.svg)](https://index.scala-lang.org/neandertech/smithy4s-fetch/smithy4s-fetch)\n\n- **SBT**: `libraryDependencies += \"tech.neander\" %%% \"smithy4s-fetch\" % \"\u003clatest version\u003e\"`\n- **Scala CLI**: `//\u003e using dep tech.neander::smithy4s-fetch::\u003clatest version\u003e`\n- **Mill**: `ivy\"tech.neander::smithy4s-fetch::\u003clatest version\u003e\"`\n\n## Getting started\n\nFor example's sake, let's say we have a smithy4s service that models one of the endpoints from https://httpbin.org, defined using [smithy4s-deriving](https://github.com/neandertech/smithy4s-deriving) (note we're using [Scala CLI](https://scala-cli.virtuslab.org) for this demo):\n\n```scala\n//\u003e using dep \"tech.neander::smithy4s-deriving::0.0.2\"\n//\u003e using platform scala-js\n//\u003e using scala 3.4.2\n//\u003e using option -Wunused:all\n\nimport smithy4s.*\n\nimport scala.annotation.experimental\nimport scala.scalajs.js.Promise\n\nimport deriving.{given, *}\nimport aliases.*\n\ncase class Response(headers: Map[String, String], origin: String, url: String)\n    derives Schema\n\n@experimental\ntrait HttpbinService derives API:\n  @readonly\n  @httpGet(\"/get\")\n  def get(): Promise[Response]\n```\n\n***Note** that we only need to use `@experimental` annotation because we are using smithy4s-deriving.*\n*If you're creating clients for services generated by standard Smithy4s codegen, just remove all `@experimental` annotations*\n*you see.*\n\nTo create a Fetch client for this service all we need to do is this:\n\n```scala\nimport smithy4s_fetch.*\n\n@main @experimental\ndef helloWorld = \n  val service: HttpbinService = \n    SimpleRestJsonFetchClient(\n      API.service[HttpbinService],\n      \"https://httpbin.org\"\n     ).make.unliftService\n\n  service.get().`then`(v =\u003e println(v))\n```\n\nIf your locally installed Node.js version is higher than 18 (version where `fetch` was added into Node.js), then you can run this example for youreself by running `make run-example`\n\n## Contributing\n\nIf you see something that can be improved in this library – please contribute!\n\nThis is a relatively standard Scala CLI project, even though the tests run a \nScala version newer than the library itself (library is published for 3.3, tests are \nin 3.4, to make use of smithy4s-deriving).\n\nHere are some useful commands:\n\n- `make test` – run tests\n- `make check-docs` – verify that snippets in `README.md` (this file) compile\n- `make pre-ci` – format the code so that it passes CI check\n- `make run-example` – run example from README against real https://httpbin.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneandertech%2Fsmithy4s-fetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneandertech%2Fsmithy4s-fetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneandertech%2Fsmithy4s-fetch/lists"}