{"id":22070024,"url":"https://github.com/tashuo/nest-websocket","last_synced_at":"2025-10-11T17:30:41.833Z","repository":{"id":186608008,"uuid":"627420851","full_name":"tashuo/nest-websocket","owner":"tashuo","description":"nest websocket example","archived":false,"fork":false,"pushed_at":"2023-04-14T08:39:42.000Z","size":98,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T20:36:06.866Z","etag":null,"topics":["jwt","nest","nestjs","nodejs","socket-io","typeorm","websocket"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tashuo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-04-13T12:37:51.000Z","updated_at":"2025-01-16T04:00:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"1813b170-19f1-43ec-9a79-807f2de344c9","html_url":"https://github.com/tashuo/nest-websocket","commit_stats":null,"previous_names":["tashuo/nest-websocket"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tashuo/nest-websocket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tashuo%2Fnest-websocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tashuo%2Fnest-websocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tashuo%2Fnest-websocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tashuo%2Fnest-websocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tashuo","download_url":"https://codeload.github.com/tashuo/nest-websocket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tashuo%2Fnest-websocket/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279008116,"owners_count":26084396,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"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":["jwt","nest","nestjs","nodejs","socket-io","typeorm","websocket"],"created_at":"2024-11-30T20:14:28.837Z","updated_at":"2025-10-11T17:30:41.549Z","avatar_url":"https://github.com/tashuo.png","language":"TypeScript","funding_links":["https://opencollective.com/nest","https://paypal.me/kamilmysliwiec"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://nestjs.com/\" target=\"blank\"\u003e\u003cimg src=\"https://nestjs.com/img/logo-small.svg\" width=\"200\" alt=\"Nest Logo\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456\n[circleci-url]: https://circleci.com/gh/nestjs/nest\n\n  \u003cp align=\"center\"\u003eA progressive \u003ca href=\"http://nodejs.org\" target=\"_blank\"\u003eNode.js\u003c/a\u003e framework for building efficient and scalable server-side applications.\u003c/p\u003e\n    \u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/~nestjscore\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@nestjs/core.svg\" alt=\"NPM Version\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/~nestjscore\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/@nestjs/core.svg\" alt=\"Package License\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/~nestjscore\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/@nestjs/common.svg\" alt=\"NPM Downloads\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://circleci.com/gh/nestjs/nest\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/circleci/build/github/nestjs/nest/master\" alt=\"CircleCI\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://coveralls.io/github/nestjs/nest?branch=master\" target=\"_blank\"\u003e\u003cimg src=\"https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9\" alt=\"Coverage\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://discord.gg/G7Qnnhy\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/discord-online-brightgreen.svg\" alt=\"Discord\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nest#backer\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/nest/backers/badge.svg\" alt=\"Backers on Open Collective\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nest#sponsor\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/nest/sponsors/badge.svg\" alt=\"Sponsors on Open Collective\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://paypal.me/kamilmysliwiec\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/Donate-PayPal-ff3f59.svg\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://opencollective.com/nest#sponsor\"  target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg\" alt=\"Support us\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://twitter.com/nestframework\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/nestframework.svg?style=social\u0026label=Follow\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n  \u003c!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)\n  [![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)--\u003e\n\n## Description\nA nest websocket example with auth.\n\n实现了websocket连接鉴权、心跳保活、私聊和系统主动推送通知等逻辑\n\n## Installation\n\n```bash\n# install\n$ pnpm up -latest\n\n# .env\n$ cp .env.example .env # modify the config with yours\n\n# run migration\n$ pnpm typeorm:run-migrations\n```\n\n## Running the app\n\n```bash\n# development\n$ pnpm start\n\n# watch mode\n$ pnpm start:dev\n```\n\n## Test\n### login to get jwt\n*the test users Jim and John are auto generated on nest start, look at [OnApplicationBootstrap](https://github.com/tashuo/nest-websocket/blob/master/src/modules/user/user.module.ts)*\n\n```bash\n$ curl -X POST \\\n  '127.0.0.1:3000/user/login' \\\n  --header 'Content-Type: application/json' \\\n  --data-raw '{\n  \"username\": \"Jim\",\n  \"password\": \"123456\"\n}'\n\n$ curl -X POST \\\n  '127.0.0.1:3000/user/login' \\\n  --header 'Content-Type: application/json' \\\n  --data-raw '{\n  \"username\": \"John\",\n  \"password\": \"123456\"\n}'\n```\n\n### test with Postman\n#### connect to ws server with jwt token\n\n[![ixBr6Q.md.png](https://i.328888.xyz/2023/04/14/ixBr6Q.md.png)](https://imgloc.com/i/ixBr6Q)\n\n#### add chat event listener\n[![ixBGld.md.png](https://i.328888.xyz/2023/04/14/ixBGld.md.png)](https://imgloc.com/i/ixBGld)\n\n#### send message directly with ws\n[![ixBYc5.md.png](https://i.328888.xyz/2023/04/14/ixBYc5.md.png)](https://imgloc.com/i/ixBYc5)\n\n[![ixXVGH.md.png](https://i.328888.xyz/2023/04/14/ixXVGH.md.png)](https://imgloc.com/i/ixXVGH)\n\n#### send message with http api\n[![ixXO7d.md.png](https://i.328888.xyz/2023/04/14/ixXO7d.md.png)](https://imgloc.com/i/ixXO7d)\n\n[![ixXev5.md.png](https://i.328888.xyz/2023/04/14/ixXev5.md.png)](https://imgloc.com/i/ixXev5)\n\n### test heartbeat\n#### normal\n[![ixgprJ.md.png](https://i.328888.xyz/2023/04/14/ixgprJ.md.png)](https://imgloc.com/i/ixgprJ)\n\n#### timeout\n[![ixgdDz.md.png](https://i.328888.xyz/2023/04/14/ixgdDz.md.png)](https://imgloc.com/i/ixgdDz)\n\n## License\n\nNest is [MIT licensed](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftashuo%2Fnest-websocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftashuo%2Fnest-websocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftashuo%2Fnest-websocket/lists"}