{"id":17084546,"url":"https://github.com/nsaunders/trout-demo","last_synced_at":"2026-01-04T08:43:45.935Z","repository":{"id":98734564,"uuid":"225780461","full_name":"nsaunders/trout-demo","owner":"nsaunders","description":"Trout and code sharing in PureScript","archived":false,"fork":false,"pushed_at":"2019-12-15T17:16:03.000Z","size":35,"stargazers_count":23,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T20:12:28.002Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PureScript","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/nsaunders.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":"2019-12-04T04:40:34.000Z","updated_at":"2023-09-23T02:50:32.000Z","dependencies_parsed_at":"2023-05-25T01:45:45.569Z","dependency_job_id":null,"html_url":"https://github.com/nsaunders/trout-demo","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/nsaunders%2Ftrout-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsaunders%2Ftrout-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsaunders%2Ftrout-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsaunders%2Ftrout-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nsaunders","download_url":"https://codeload.github.com/nsaunders/trout-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245111928,"owners_count":20562511,"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-14T13:07:55.525Z","updated_at":"2026-01-04T08:43:45.878Z","avatar_url":"https://github.com/nsaunders.png","language":"PureScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# trout-demo [![build status](https://img.shields.io/travis/nsaunders/trout-demo.svg)](https://travis-ci.org/nsaunders/trout-demo)\n## Trout and code sharing in PureScript\n\n[Trout](https://github.com/purescript-hyper/purescript-trout) is a type-level routing DSL. Similar to Haskell's [Servant](https://github.com/haskell-servant/servant) library, Trout allows routes to be specified as a data type. For example, a `GET /api/tasks` route that responds with an `Array Task` in JSON format can be represented as `\"api\" :/ \"tasks\" :\u003e Resource (Get (Array Task) JSON)`. Trout provides various combinators for matching literal URL segments, parsing route parameters, extracting headers, reading the request body, and more.\n\nMultiple options exist for building an HTTP server from a Trout specification. These are helpful because they allow request handlers to focus on domain logic rather than uninteresting protocol-level details. One such option is [`purescript-hypertrout`](https://github.com/purescript-hyper/purescript-hypertrout), originally by [Oskar Wickström](https://wickstrom.tech), who also designed Trout. The library used here, however, is [`purescript-nodetrout`](https://github.com/nsaunders/purescript-nodetrout).\n\nSimilarly, on the client side, the [`purescript-trout-client`](https://github.com/purescript-hyper/purescript-trout-client) library can generate a convenient interface that hides the low-level details of building an HTTP request, e.g. constructing the URL from various parameters or serializing the request payload.\n\nUsing these tools, the [server](src/Server.purs) and [client](src/Client.purs) layers of this application are constructed from the same [API specification](src/API.purs). Because the server and client are both written in PureScript, sharing types and even functions is effortless. The [`Credentials`](src/Credentials.purs) and [`Task`](src/Task.purs) modules, for example, are used both server-side and client-side.\n\n### Building and running the app\n\nUsing [Spago](https://github.com/spacchetti/spago):\n\n```\nspago bundle-app --to static/app.js --main Client \u0026\u0026 spago run --main Server\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsaunders%2Ftrout-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnsaunders%2Ftrout-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsaunders%2Ftrout-demo/lists"}