{"id":26806792,"url":"https://github.com/talentlessguy/tinyws","last_synced_at":"2025-03-30T00:01:52.086Z","repository":{"id":38268268,"uuid":"366096250","full_name":"tinyhttp/tinyws","owner":"tinyhttp","description":"🚡 tiny WebSocket middleware for Node.js","archived":false,"fork":false,"pushed_at":"2023-09-24T15:43:14.000Z","size":279,"stargazers_count":398,"open_issues_count":1,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-23T07:54:51.490Z","etag":null,"topics":["express","http","javascript","nodejs","polka","server","tinyhttp","websocket","ws"],"latest_commit_sha":null,"homepage":"https://npm.im/tinyws","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/tinyhttp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"ko_fi":"v1rtl","liberapay":"v1rtl","issuehunt":"talentlessguy","github":["talentlessguy"]}},"created_at":"2021-05-10T15:48:25.000Z","updated_at":"2024-06-18T13:54:11.777Z","dependencies_parsed_at":"2024-06-18T13:54:04.204Z","dependency_job_id":"cb9a5cbb-0b7c-4672-aeef-d9c32e4babde","html_url":"https://github.com/tinyhttp/tinyws","commit_stats":null,"previous_names":["talentlessguy/tinyws"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Ftinyws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Ftinyws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Ftinyws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinyhttp%2Ftinyws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinyhttp","download_url":"https://codeload.github.com/tinyhttp/tinyws/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246258866,"owners_count":20748573,"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":["express","http","javascript","nodejs","polka","server","tinyhttp","websocket","ws"],"created_at":"2025-03-30T00:01:05.091Z","updated_at":"2025-03-30T00:01:52.074Z","avatar_url":"https://github.com/tinyhttp.png","language":"TypeScript","readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/tinyhttp/tinyws/master/logo.svg\" alt=\"tinyws\"\u003e\n\u003cp\u003e\u003csub\u003e🚡 tiny WebSocket middleware for Node.js\u003c/sub\u003e\u003c/p\u003e\n\u003cbr /\u003e\n\n[![Version][v-badge-url]][npm-url] [![Downloads][dl-badge-url]][npm-url] [![GitHub Workflow Status][gh-actions-img]][github-actions] [![Codecov][cov-badge-url]][cov-url]\n\n\u003c/div\u003e\n\n_**tinyws**_ is a WebSocket middleware for Node.js based on [ws](https://github.com/websockets/ws), inspired by [koa-easy-ws](https://github.com/b3nsn0w/koa-easy-ws).\n\nCheck the [chat example](examples/chat) out to get familiar with tinyws.\n\n## Features\n\n- Small size (**498B**)\n- Easy to use (only `req.ws` and nothing else)\n- Framework-agnostic (works with tinyhttp, express etc)\n- Written in TypeScript\n- Pure ESM\n\n## Why not [express-ws](https://github.com/HenningM/express-ws)?\n\nbecause express-ws is...\n\n- [Abandoned](https://github.com/HenningM/express-ws/issues/135) since 2018 💀\n- Doesn't come with types out of the box (have to install `@types/express-ws`)\n- Not compatible with tinyhttp and polka\n- Buggy as hell\n- Doesn't have tests\n\n## Install\n\n```sh\npnpm i ws tinyws\n```\n\n## Example\n\n```ts\nimport { App, Request } from '@tinyhttp/app'\nimport { tinyws, TinyWSRequest } from 'tinyws'\n\nconst app = new App\u003cany, Request \u0026 TinyWSRequest\u003e()\n\napp.use(tinyws())\n\napp.use('/ws', async (req, res) =\u003e {\n  if (req.ws) {\n    const ws = await req.ws()\n\n    return ws.send('hello there')\n  } else {\n    res.send('Hello from HTTP!')\n  }\n})\n\napp.listen(3000)\n```\n\nSee [examples](examples) for express and polka integration.\n\n[v-badge-url]: https://img.shields.io/npm/v/tinyws.svg?style=for-the-badge\u0026color=F55A5A\u0026label=\u0026logo=npm\n[npm-url]: https://www.npmjs.com/package/tinyws\n[cov-badge-url]: https://img.shields.io/coveralls/github/tinyhttp/tinyws?style=for-the-badge\u0026color=F55A5A\n[cov-url]: https://coveralls.io/github/tinyhttp/tinyws\n[dl-badge-url]: https://img.shields.io/npm/dt/tinyws?style=for-the-badge\u0026color=F55A5A\n[github-actions]: https://github.com/tinyhttp/tinyws/actions\n[gh-actions-img]: https://img.shields.io/github/actions/workflow/status/tinyhttp/tinyws/main.yml?branch=master\u0026style=for-the-badge\u0026color=F55A5A\u0026label=\u0026logo=github\n","funding_links":["https://ko-fi.com/v1rtl","https://liberapay.com/v1rtl","https://issuehunt.io/r/talentlessguy","https://github.com/sponsors/talentlessguy"],"categories":["Packages"],"sub_categories":["Middleware"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalentlessguy%2Ftinyws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftalentlessguy%2Ftinyws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalentlessguy%2Ftinyws/lists"}