{"id":16809501,"url":"https://github.com/asyncapi/nodejs-ws-template","last_synced_at":"2025-04-05T06:03:54.781Z","repository":{"id":37907223,"uuid":"248822851","full_name":"asyncapi/nodejs-ws-template","owner":"asyncapi","description":"Node.js WebSockets template for the AsyncAPI Generator. It showcases how from a single AsyncAPI document you can generate a server and a client at the same time.","archived":false,"fork":false,"pushed_at":"2024-10-14T17:07:41.000Z","size":5225,"stargazers_count":25,"open_issues_count":8,"forks_count":29,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-29T22:38:04.594Z","etag":null,"topics":["asyncapi","generator","get-global-node-release-workflows","get-global-releaserc","nodejs","template","websocket","websockets"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/asyncapi.png","metadata":{"funding":{"github":"asyncapi","patreon":null,"open_collective":"asyncapi","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null},"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-20T18:13:45.000Z","updated_at":"2024-10-15T22:59:28.000Z","dependencies_parsed_at":"2023-12-15T22:06:22.830Z","dependency_job_id":"7af8853e-07ee-4365-a736-ca0a5759ecb1","html_url":"https://github.com/asyncapi/nodejs-ws-template","commit_stats":{"total_commits":308,"total_committers":12,"mean_commits":"25.666666666666668","dds":0.25,"last_synced_commit":"7d696f6084833910dd2d586ed60b23ecb6906ef4"},"previous_names":[],"tags_count":57,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncapi%2Fnodejs-ws-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncapi%2Fnodejs-ws-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncapi%2Fnodejs-ws-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asyncapi%2Fnodejs-ws-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asyncapi","download_url":"https://codeload.github.com/asyncapi/nodejs-ws-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294516,"owners_count":20915340,"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":["asyncapi","generator","get-global-node-release-workflows","get-global-releaserc","nodejs","template","websocket","websockets"],"created_at":"2024-10-13T10:13:01.797Z","updated_at":"2025-04-05T06:03:54.761Z","avatar_url":"https://github.com/asyncapi.png","language":"JavaScript","readme":"[![AsyncAPI logo](./assets/github-repobanner-nodewstemp.png)](https://www.asyncapi.com)\n\n![npm](https://img.shields.io/npm/v/@asyncapi/nodejs-ws-template?style=for-the-badge) ![npm](https://img.shields.io/npm/dt/@asyncapi/nodejs-ws-template?style=for-the-badge)\n\n\u003c!-- toc is generated with GitHub Actions do not remove toc markers --\u003e\n\n\u003c!-- toc --\u003e\n\n- [Overview](#overview)\n- [Technical requirements](#technical-requirements)\n- [Specification requirements](#specification-requirements)\n- [Supported protocols](#supported-protocols)\n- [How to use the template](#how-to-use-the-template)\n  * [CLI](#cli)\n- [Template configuration](#template-configuration)\n- [Custom hooks that you can disable](#custom-hooks-that-you-can-disable)\n- [Development](#development)\n- [Contributors](#contributors)\n\n\u003c!-- tocstop --\u003e\n\n## Overview\n\nThis template generates two resources related to WebSockets:\n- Server application with WebSocket endpoint based on [Express.js](https://expressjs.com/)\n- Client HTML file with simple scripts that give you a basic API to talk to the server\n\nOther files are for the setup of developer environment, like `.editorconfig` or `.eslint`.\n\n## Technical requirements\n\n- 0.50.0 =\u003c [Generator](https://github.com/asyncapi/generator/) \u003c 2.0.0,\n- Generator specific [requirements](https://github.com/asyncapi/generator/#requirements)\n\n\n## Specification requirements\n\nThis is a very early version of the template and not all specification features are supported:\n\nProperty name | Reason | Fallback | Default\n---|---|---|---\n`servers.*.url` | Template doesn't support variables in the server url. | - | -\n`bindings` | Template doesn't use [websockets](https://github.com/asyncapi/bindings/tree/master/websockets) bindings.| - | -\n`operationId` | Operation ID must be set for every operation to generate proper functions as there is no fallback in place | - | -\n\n## Supported protocols\n\n[WebSocket](https://en.wikipedia.org/wiki/WebSocket)\n\n## How to use the template\n\nThis template must be used with the AsyncAPI Generator. You can find all available options [here](https://github.com/asyncapi/generator/).\n\n### CLI\n\n```bash\n# Install the AsyncAPI Generator\nnpm install -g @asyncapi/generator\n\n# Run generation\nag https://raw.githubusercontent.com/asyncapi/generator/v1.4.0/test/docs/ws.yml @asyncapi/nodejs-ws-template -o output -p server=localhost\n\n##\n## Start the server \n##\n\n# Go to the generated server\ncd output\n\n# Build generated application\nnpm i\n\n# Start server\nnpm start\n\n##\n## Start the client \n##\n\n# From another terminal tab open generated HTML in browser\nopen output/index.html\n\n# Open developers console and follow instructions from there\n# Connect with server\nlisten('/echo')\n\n# Send example message\nsend({ greet: 'Hello from client' })\n\n# You should see the sent message in the logs of the previously started server\n```\n\n## Template configuration\n\nYou can configure this template by passing different parameters in the Generator CLI: `-p PARAM1_NAME=PARAM1_VALUE -p PARAM2_NAME=PARAM2_VALUE`\n\n| Name | Description | Required | Default | Allowed Values | Example\n|---|---|---|---|---|---|\n|server|The server you want to use in the code.|Yes| - | Name of the server from the list of servers under Servers object | `localhost`|\n\n\n## Custom hooks that you can disable\n\nThe functionality of this template is extended with different hooks that you can disable like this in the Generator CLI: `-d HOOK_TYPE1=HOOK_NAME1,HOOK_NAME2 -d HOOK_TYPE2`\n\nType | Name | Description\n---|---|---\ngenerate:after | createAsyncapiFile | It creates AsyncAPI file with content of the spec file passed to the generator\n\n## Development\n\nThe most straightforward command to use this template is:\n```bash\nag https://raw.githubusercontent.com/asyncapi/generator/v1.4.0/test/docs/ws.yml @asyncapi/nodejs-ws-template -o output -p server=localhost\n```\n\nFor local development, you need different variations of this command. First of all, you need to know about three important CLI flags:\n- `--debug` enables the debug mode in Nunjucks engine what makes filters debugging simpler. \n- `--watch-template` enables a watcher of changes that you make in the template. It regenerates your template whenever it detects a change.\n- `--install` enforces reinstallation of the template.\n\n\nThere are two ways you can work on template development:\n- Use global Generator and template from your local sources:\n  ```bash\n  # assumption is that you run this command from the root of your template\n  ag https://raw.githubusercontent.com/asyncapi/generator/v1.4.0/test/docs/ws.yml ./ -o output\n  ```\n- Use Generator from sources and template also from local sources. This approach enables more debugging options with awesome `console.log` in the Generator sources or even the Parser located in `node_modules` of the Generator:\n  ```bash\n  # assumption is that you run this command from the root of your template\n  # assumption is that generator sources are cloned on the same level as the template\n  ../generator/cli.js https://raw.githubusercontent.com/asyncapi/generator/v1.4.0/test/docs/ws.yml ./ -o output\n  ```\n\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"http://www.fmvilas.com/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/242119?v=4?s=100\" width=\"100px;\" alt=\"Fran Méndez\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eFran Méndez\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/asyncapi/nodejs-ws-template/commits?author=fmvilas\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#ideas-fmvilas\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://dev.to/derberg\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/6995927?v=4?s=100\" width=\"100px;\" alt=\"Lukasz Gornicki\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eLukasz Gornicki\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#infra-derberg\" title=\"Infrastructure (Hosting, Build-Tools, etc)\"\u003e🚇\u003c/a\u003e \u003ca href=\"https://github.com/asyncapi/nodejs-ws-template/commits?author=derberg\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/asyncapi/nodejs-ws-template/pulls?q=is%3Apr+reviewed-by%3Aderberg\" title=\"Reviewed Pull Requests\"\u003e👀\u003c/a\u003e \u003ca href=\"#maintenance-derberg\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e \u003ca href=\"https://github.com/asyncapi/nodejs-ws-template/commits?author=derberg\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"#blog-derberg\" title=\"Blogposts\"\u003e📝\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://aayushsahu.com\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/54525741?v=4?s=100\" width=\"100px;\" alt=\"Aayush Kumar Sahu\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAayush Kumar Sahu\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#security-aayushmau5\" title=\"Security\"\u003e🛡️\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/KatrinaAS\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/690546?v=4?s=100\" width=\"100px;\" alt=\"Katrina Knight\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eKatrina Knight\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#infra-KatrinaAS\" title=\"Infrastructure (Hosting, Build-Tools, etc)\"\u003e🚇\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/RageZBla\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/1196871?v=4?s=100\" width=\"100px;\" alt=\"Olivier Lechevalier\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eOlivier Lechevalier\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/asyncapi/nodejs-ws-template/commits?author=RageZBla\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"https://github.com/Krishks369\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/71367204?v=4?s=100\" width=\"100px;\" alt=\"Krishna Kumar S\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eKrishna Kumar S\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/asyncapi/nodejs-ws-template/commits?author=Krishks369\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"14.28%\"\u003e\u003ca href=\"http://ivankahl.com/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/5931577?v=4?s=100\" width=\"100px;\" alt=\"Ivan Kahl\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eIvan Kahl\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/asyncapi/nodejs-ws-template/commits?author=ivankahl\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/asyncapi/nodejs-ws-template/commits?author=ivankahl\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!","funding_links":["https://github.com/sponsors/asyncapi","https://opencollective.com/asyncapi"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasyncapi%2Fnodejs-ws-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasyncapi%2Fnodejs-ws-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasyncapi%2Fnodejs-ws-template/lists"}