{"id":13569243,"url":"https://github.com/MystPi/glen","last_synced_at":"2025-04-04T05:31:46.146Z","repository":{"id":220131984,"uuid":"750538787","full_name":"MystPi/glen","owner":"MystPi","description":"🏕️ A peaceful web framework for Gleam that targets JS.","archived":false,"fork":false,"pushed_at":"2024-02-29T21:07:42.000Z","size":1221,"stargazers_count":36,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-16T19:05:09.002Z","etag":null,"topics":["cloudflare-workers","deno","deno-deploy","gleam","gleam-lang","javascript","web","web-framework"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/glen/","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/MystPi.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}},"created_at":"2024-01-30T20:37:57.000Z","updated_at":"2024-08-01T14:31:22.070Z","dependencies_parsed_at":"2024-08-01T14:31:21.612Z","dependency_job_id":"746c2c86-c34a-40fb-a5ae-9e1991c24a89","html_url":"https://github.com/MystPi/glen","commit_stats":null,"previous_names":["mystpi/glen"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MystPi%2Fglen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MystPi%2Fglen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MystPi%2Fglen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MystPi%2Fglen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MystPi","download_url":"https://codeload.github.com/MystPi/glen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247128702,"owners_count":20888232,"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":["cloudflare-workers","deno","deno-deploy","gleam","gleam-lang","javascript","web","web-framework"],"created_at":"2024-08-01T14:00:37.513Z","updated_at":"2025-04-04T05:31:45.434Z","avatar_url":"https://github.com/MystPi.png","language":"Gleam","readme":"# glen\n\n\u003cimg src=\"https://raw.githubusercontent.com/MystPi/glen/main/assets/glen.png\" width=\"150\" align=\"right\" /\u003e\n\n[![Package Version](https://img.shields.io/hexpm/v/glen)](https://hex.pm/packages/glen)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/glen/)\n\n🏕️ A peaceful web framework for Gleam that targets JS.\n\n✨ Features:\n\n- Request \u0026 response helpers\n- Helpful middleware\n- File streaming\n- Websockets\n- Bring-your-own server _(optional)_\n- Easily deploy on serverless platforms such as [Deno Deploy](https://deno.com/deploy)\n\n...and other nice-to-haves!\n\n## Installation\n\nInstall all requirements:\n\n```sh\ngleam add glen gleam_http gleam_javascript\n```\n\nOr just Glen:\n\n```sh\ngleam add glen\n```\n\n## Usage\n\n```gleam\nimport gleam/javascript/promise.{type Promise}\nimport glen\nimport glen/status\n\npub fn main() {\n  glen.serve(8000, handle_req)\n}\n\nfn handle_req(req: glen.Request) -\u003e Promise(glen.Response) {\n  \"\u003ch1\u003eWelcome to my webpage!\u003c/h1\u003e\n  \u003cp\u003eMake yourself at home 😄\u003c/p\u003e\"\n  |\u003e glen.html(status.ok)\n  |\u003e promise.resolve\n}\n```\n\nGlen is heavily based off of [Wisp](https://github.com/gleam-wisp/wisp), and many of Wisp's [examples](https://github.com/gleam-wisp/wisp/tree/main/examples) can easily be ported to Glen. Glen also has an example application of its own in [./test](https://github.com/MystPi/glen/tree/main/test).\n\n## Bring-your-own server\n\nGlen's `serve` function only works on the `deno` runtime, but you can bring your own server so Glen can work on any runtime, such as Node.js (\u003e= v17.0.0) or Cloudflare Workers. The `convert_request` and `convert_response` functions are here to help you with this.\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cb\u003eCloudflare Workers example\u003c/b\u003e\n  \u003c/summary\u003e\n\n\u003e Glen's `static` middleware will not work on the Cloudflare Workers runtime since it does not support the `node:fs` module. Everything else should work as expected.\n\n`src/index.js`\n\n```js\nimport * as glen from '../glen/glen.mjs';\nimport * as my_app from './my_app.mjs';\n\nexport default {\n  async fetch(request, _env, _ctx) {\n    const req = glen.convert_request(request);\n    const response = await my_app.handle_req(req);\n    const res = glen.convert_response(response);\n\n    return res;\n  },\n};\n```\n\n`src/my_app.gleam`\n\n```gleam\nimport gleam/javascript/promise\nimport glen\nimport glen/status\n\npub fn handle_req(_req) {\n  \"On a Cloudflare worker!\"\n  |\u003e glen.html(status.ok)\n  |\u003e promise.resolve\n}\n```\n\n`wrangler.toml`\n\n```toml\nmain = \"build/dev/javascript/my_app/index.js\"\n# ...\n```\n\n\u003c/details\u003e\n\n## Docs\n\nDocumentation can be found at \u003chttps://hexdocs.pm/glen\u003e.\n\n## Development \u0026 Contributing\n\nYou will need to have Gleam and a JavaScript runtime (most likely Deno) installed for developing Glen.\n\n```sh\ngleam run   # Run the project\ngleam test  # Run the example application\n```\n\nContributions are encouraged and greatly appreciated! Please note that the [changelog](CHANGELOG.md) should be updated accordingly (this is something that everyone has trouble remembering, including me 😅).","funding_links":[],"categories":["Gleam","Packages"],"sub_categories":["Web frameworks"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMystPi%2Fglen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMystPi%2Fglen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMystPi%2Fglen/lists"}