{"id":22010462,"url":"https://github.com/virtualstate/listen","last_synced_at":"2026-04-18T14:35:39.166Z","repository":{"id":58563021,"uuid":"532439430","full_name":"virtualstate/listen","owner":"virtualstate","description":"Fetch listener","archived":false,"fork":false,"pushed_at":"2022-10-14T09:14:26.000Z","size":499,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-13T19:43:55.686Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/virtualstate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-04T04:39:28.000Z","updated_at":"2022-10-04T02:22:05.000Z","dependencies_parsed_at":"2023-01-20T06:15:37.519Z","dependency_job_id":null,"html_url":"https://github.com/virtualstate/listen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/virtualstate/listen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Flisten","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Flisten/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Flisten/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Flisten/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/virtualstate","download_url":"https://codeload.github.com/virtualstate/listen/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualstate%2Flisten/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31972573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-30T02:13:10.102Z","updated_at":"2026-04-18T14:35:39.149Z","avatar_url":"https://github.com/virtualstate.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@virtualstate/listen`\n\nFetch listener\n\n[//]: # (badges)\n\n### Support\n\n ![Node.js supported](https://img.shields.io/badge/node-%3E%3D18.7.0-blue) ![Deno supported](https://img.shields.io/badge/deno-%3E%3D1.17.0-blue) ![Bun supported](https://img.shields.io/badge/bun-%3E%3D0.1.11-blue) \n\n### Test Coverage\n\n ![96.69%25 lines covered](https://img.shields.io/badge/lines-96.69%25-brightgreen) ![96.69%25 statements covered](https://img.shields.io/badge/statements-96.69%25-brightgreen) ![95.65%25 functions covered](https://img.shields.io/badge/functions-95.65%25-brightgreen) ![90.57%25 branches covered](https://img.shields.io/badge/branches-90.57%25-brightgreen)\n\n[//]: # (badges)\n\n# Usage\n\n```typescript\nimport { listen } from \"@virtualstate/listen\";\n\nconst { url, close } = await listen(\n    event =\u003e event.respondWith(new Response(\"Hello!\"))\n);\n\nconsole.log(`Listening on ${url}`);\n\nconst response = await fetch(url);\nconst text = await response.text();\nconsole.log(text);\n\nif (text !== \"Hello!\") throw new Error(\"Expected Hello!\");\n\nawait close();\n```\n\n## JSX\n\n```jsx\nimport { listen, toResponse, toAsyncString, Fetch } from \"@virtualstate/listen\";\nimport { h, descendants, name, properties } from \"@virtualstate/focus\";\n\nasync function *App({ request }) {\n    if (request.method === \"POST\") {\n        const body = JSON.parse(\n            await toAsyncString(request)\n        );\n        yield \u003cecho {...body} /\u003e\n    }\n}\n\nconst { url, close } = await listen(\n    event =\u003e event.respondWith(\n        toResponse(\u003cApp request={event.request} /\u003e)\n    )\n);\n\nconst random = Math.random()\nconst {\n    echo: [echo]\n} = descendants(\n    \u003cFetch \n        url={url}\n        method=\"POST\"\n        body={JSON.stringify({\n            random\n        })}\n    /\u003e\n).group(name);\n\nconst body = properties(await echo);\nconsole.log(body);\n\nif (body.random !== random) throw new Error(\"Expected body to contain random\")\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtualstate%2Flisten","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirtualstate%2Flisten","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtualstate%2Flisten/lists"}