{"id":28239471,"url":"https://github.com/codedownio/servant-typescript","last_synced_at":"2025-06-29T23:34:03.048Z","repository":{"id":43078957,"uuid":"470943381","full_name":"codedownio/servant-typescript","owner":"codedownio","description":"TypeScript client generation for Servant","archived":false,"fork":false,"pushed_at":"2025-06-03T12:52:44.000Z","size":42,"stargazers_count":25,"open_issues_count":2,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-03T21:57:12.813Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codedownio.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","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,"zenodo":null}},"created_at":"2022-03-17T10:18:35.000Z","updated_at":"2025-06-03T12:52:44.000Z","dependencies_parsed_at":"2025-06-03T14:09:17.069Z","dependency_job_id":"81dd97f7-5b0c-41d5-85e7-b79d5405d1a7","html_url":"https://github.com/codedownio/servant-typescript","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codedownio%2Fservant-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codedownio%2Fservant-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codedownio%2Fservant-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codedownio%2Fservant-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codedownio","download_url":"https://codeload.github.com/codedownio/servant-typescript/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codedownio%2Fservant-typescript/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259221861,"owners_count":22823975,"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":"2025-05-19T02:12:30.295Z","updated_at":"2025-06-11T07:31:00.651Z","avatar_url":"https://github.com/codedownio.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Welcome to `servant-typescript` [![Hackage](https://img.shields.io/hackage/v/servant-typescript.svg)](https://hackage.haskell.org/package/servant-typescript) ![servant-typescript](https://github.com/codedownio/servant-typescript/workflows/servant-typescript/badge.svg)\n\n\nThis library generates TypeScript client libraries for Servant.\n\nFirst, make sure you have [TypeScript](https://hackage.haskell.org/package/aeson-typescript) instances defined for all of the types used in the API.\n\n```haskell\ndata User = User {\n  name :: String\n  , age :: Int\n  , email :: String\n  } deriving (Eq, Show)\nderiveJSONAndTypeScript A.defaultOptions ''User\n```\n\nIf you need to generate lots of boilerplate instances, the functions in `aeson-typescript`'s [Recursive](https://hackage.haskell.org/package/aeson-typescript-0.4.0.0/docs/Data-Aeson-TypeScript-Recursive.html) module can be your friend.\nI've used [recursivelyDeriveMissingTypeScriptInstancesFor](https://hackage.haskell.org/package/aeson-typescript-0.4.0.0/docs/Data-Aeson-TypeScript-Recursive.html#v:recursivelyDeriveMissingTypeScriptInstancesFor) to derive instances for the Kubernetes API.\n\nNext, you'll need some Servant API:\n\n```haskell\ntype UserAPI = \"users\" :\u003e Get '[JSON] [User]\n          :\u003c|\u003e \"albert\" :\u003e Get '[JSON] User\n          :\u003c|\u003e \"isaac\" :\u003e Get '[JSON] User\n```\n\nGenerating the library is as simple as this:\n\n```haskell\nmain = writeTypeScriptLibrary (Proxy :: Proxy UserAPI) \"/my/destination/folder/\"\n```\n## Caveats\n\n* This library doesn't yet support generating generic TypeScript functions to match generic TypeScript instances. You can hack around this by writing your own `getFunctions` and hardcoding them manually for the necessary types.\n\n## Supporting additional combinators\n\nIf you use unusual Servant combinators in your API, you may need to define additional `HasForeign` instances to explain how to convert them to TypeScript. For example, when I work with the [servant-websockets](https://hackage.haskell.org/package/servant-websockets) package, I add instances like the following.\n\nThe same applies to custom `AuthProtect` combinators from [Servant.API.Experimental.Auth](https://hackage.haskell.org/package/servant-0.19/docs/Servant-API-Experimental-Auth.html), etc.\n\n```haskell\ninstance HasForeign LangTS Text WebSocket where\n    type Foreign Text WebSocket = Text\n    foreignFor _ _ _ _ = \"void\"\n\ninstance HasForeign LangTSDecls [TSDeclaration] WebSocket where\n    type Foreign [TSDeclaration] WebSocket = [TSDeclaration]\n    foreignFor _ _ _ _ = []\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodedownio%2Fservant-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodedownio%2Fservant-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodedownio%2Fservant-typescript/lists"}