{"id":22100438,"url":"https://github.com/paologaleotti/gleamkit","last_synced_at":"2026-01-04T23:30:50.524Z","repository":{"id":246269395,"uuid":"820572645","full_name":"paologaleotti/gleamkit","owner":"paologaleotti","description":"Experimental starter for Gleam web services","archived":false,"fork":false,"pushed_at":"2024-09-29T16:53:16.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T08:51:06.070Z","etag":null,"topics":["api","backend","gleam","http","starter","template"],"latest_commit_sha":null,"homepage":"","language":"Gleam","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/paologaleotti.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":"2024-06-26T18:34:48.000Z","updated_at":"2024-09-29T16:52:23.000Z","dependencies_parsed_at":"2024-07-12T23:11:26.356Z","dependency_job_id":"71d7b950-56ed-4cc8-86cf-fccd60e2c997","html_url":"https://github.com/paologaleotti/gleamkit","commit_stats":null,"previous_names":["paologaleotti/gleamkit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paologaleotti%2Fgleamkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paologaleotti%2Fgleamkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paologaleotti%2Fgleamkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paologaleotti%2Fgleamkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paologaleotti","download_url":"https://codeload.github.com/paologaleotti/gleamkit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245195916,"owners_count":20575936,"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":["api","backend","gleam","http","starter","template"],"created_at":"2024-12-01T05:14:06.434Z","updated_at":"2026-01-04T23:30:50.494Z","avatar_url":"https://github.com/paologaleotti.png","language":"Gleam","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gleamkit\n\n\u003e WIP: Very early development, missing consistency and features\n\n![logo](https://github.com/paologaleotti/gleamkit/assets/45665769/233d9ce2-7331-494c-a8d9-345eaeadcf3a)\n\nThis experimental repo is a starter kit for writing **HTTP APIs in Gleam** based on `wisp`, \naiming to provide a simple and opinionated setup that is **production-ready**\n(even though Gleam is still a very cutting edge language).\n\nI am aware that Gleam has the \"start simple, refactor later\" philosophy (just like Golang).\nThis starter is inspired by my own [blaze](https://github.com/paologaleotti/blaze), \nonly giving the user the essentials for real, production use without going crazy on the structure.\n\n## Features\n\n- Simple, opinionated, production ready structure\n- Pattern matching based routing\n- Handy body decoding and validation\n- Automatic human readable errors on decoding failures\n- Custom HTTP API error handling\n- Request and reply utilities\n- Env variables and app context configuration\n\n## Snippets\n\nRouting:\n\n```gleam\npub fn handle_request(req: Request, _ctx: AppContext) -\u003e Response {\n  use req \u003c- middleware.default_middleware(req)\n  use req \u003c- cors.wisp_middleware(req, default_cors())\n\n  case req.method, wisp.path_segments(req) {\n    Get, [] -\u003e ok()\n    Get, [\"todos\"] -\u003e todos.handle_get_todos()\n    Post, [\"todos\"] -\u003e todos.handle_create_todo(req)\n    Get, [\"todos\", id] -\u003e todos.handle_get_todo(req, id)\n    _, _ -\u003e route_not_found()\n  }\n}\n```\n\nBody validation with automatic validation errors (found in `common/core` module):\n\n```gleam\npub fn handle_create_todo(req: Request) -\u003e Response {\n    // Handy direct decoding with custom error handling\n    use new_todo \u003c- decode_body(req, todos.decode_new_todo)\n\n    let res = todos.Todo(4, new_todo.title, False)\n\n    // Reply with status code and JSON data\n    reply_data(201, todos.encode_todo(res))\n}\n```\n\nEasy API custom error handling:\n\n```gleam\npub fn handle_get_todo(_req: Request, id: String) -\u003e Response {\n  // Early reply utility function to handle errors\n  use todo_id \u003c- unpack_or_reply(int.parse(id), fn(_) {\n    // Reply with a detailed API error\n    reply_error_detailed(BadRequest, \"Invalid todo ID\")\n  })\n\n  let item = list.find(todos, fn(t) { t.id == todo_id })\n\n  // Match on the result and reply with data or API error\n  case item {\n    Ok(item) -\u003e reply_data(200, todos.encode_todo(item))\n    Error(_) -\u003e reply_error(NotFound)\n  }\n}\n\n```\n\n\nDefault HTTP errors (like NotFound) can be found in `common/errors` module, and you can append a detail message to them using the `reply_error_detailed`  function.\n\n## Build and run\n\n```sh\nmake  # Build the project\nmake run   # Run the service\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaologaleotti%2Fgleamkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaologaleotti%2Fgleamkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaologaleotti%2Fgleamkit/lists"}