--- url: "https://asyncapi.com/docs/tutorials/generate-code" titulek: "Generate code | AsyncAPI Initiative for event-driven APIs" h1: "Generate code" popis: "import CliInstallation from '@/assets/docs/fragments/cli-installation.mdx' Introduction In this tutorial, you'll learn how to generate an application that uses the Glee framework. You'll do it with " jazyk: "en" kanonicka: "" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 21:38:49" znaku: 6082 slov: 754 kodovani: "utf-8" sha256: "82f655e9967291f00aad60eee4409e32fc322c48d76d4f163b0abc63bbb44630" --- ##### On this page Introduction Background context Installation guide Prerequisites Create a Glee project Start generated application Send message to broker Summary Next steps # Generate code Found an error? Have a suggestion?[Edit this page on GitHub](https://github.com/asyncapi/website/blob/master/markdown/docs/tutorials/generate-code.md) ## Introduction In this tutorial, you'll learn how to generate an application that uses the [Glee](https://github.com/asyncapi/glee) framework. You'll do it with an AsyncAPI document and the [AsyncAPI CLI](/tools/cli). ## Background context [Glee](https://github.com/asyncapi/glee) is a TypeScript/JavaScript framework that enables you to create APIs and messaging clients based on your AsyncAPI document. Instead of generating code, this framework tightly integrates with your AsyncAPI document and binds functions to specific AsyncAPI operations. You only have to provide the code for these functions and Glee handles the rest. Glee is often used with the [AsyncAPI CLI](/tools/cli) for a better development experience. In the previous tutorial, you created an AsyncAPI document that is used in this tutorial. ##### Remember If you did not follow the previous tutorial and do not have an `asyncapi.yaml` file for overview, then generate one by running the following command using the AsyncAPI CLI: `asyncapi new --example=tutorial.yml --no-tty`. ## Installation guide ### Prerequisites - [Node.js](https://nodejs.org/en/download/) **16 or higher** installed, which enables installation of the required dependencies using **npm** . ### CLI Installation ##### Remember Follow the [AsyncAPI CLI installation](https://github.com/asyncapi/cli#installation) instructions below, based on your computer’s operating system. macOS **Using `brew`**: You can install in macOS via brew: `brew install asyncapi`. **Using `pkg`**: Each release of CLI produces a macOS dedicated pkg file that enables you to install this CLI as macOS application. `# Download the latest release curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi.x64.pkg # Download a specific release # curl -OL https://github.com/asyncapi/cli/releases/download//asyncapi.x64.pkg # All releases are listed in https://github.com/asyncapi/cli/releases # # Install AsyncAPI CLI sudo installer -pkg asyncapi.x64.pkg -target /` LinuxYou can install in Linux via `dpkg`, a debian package manager:`curl -OL https://github.com/asyncapi/cli/releases/latest/download/asyncapi.deb sudo dpkg -i asyncapi.deb` WindowsFor Windows, install the appropriate installer and follow the default installation steps to complete the installation process. For 64-bit, download the [asyncapi.x64.exe](https://github.com/asyncapi/cli/releases/latest/download/asyncapi.x64.exe) For 32-bit, download the [asyncapi.x86.exe](https://github.com/asyncapi/cli/releases/latest/download/asyncapi.x86.exe) Other OS[Read further AsyncAPI CLI installation instructions for different operating systems](https://github.com/asyncapi/cli#installation). #### Using npm and Node.js You can install the [AsyncAPI CLI](https://github.com/asyncapi/cli#installation) with Node.js 16 or higher and [npm](https://nodejs.org/en/download/package-manager/). Install CLI globallyInstall AsyncAPI CLI *globally* with the following command:`npm install -g @asyncapi/cli` Install specific CLI versionTo install a specific version of the AsyncAPI CLI, pass the `version` during installation:`npm install -g @asyncapi/cli@{version}` ## Create a Glee project 1. Trigger the creation of the Glee project: `asyncapi new glee --name=tutorial --template=tutorial` Let's break down the previous command: - `asyncapi new glee` is how you use Glee via the AsyncAPI CLI. - `--name=tutorial` is how you tell the AsyncAPI CLI to name your new Glee project. - `--template=tutorial` is how you tell the AsyncAPI CLI to use the template of a Glee project that was created specifically for this tutorial. 2. List all files in the directory and confirm your Glee project creation: `cd tutorial && ls` Upon execution of the command above, the following is an example of the expected result: `$ ls LICENSE README.md asyncapi.yaml functions package.json` ## Start generated application 1. Install dependencies of the newly generated application: `npm install` 2. Start the application: `npm run dev` ## Send message to broker 1. In another terminal install the MQTT.js library: `npm install mqtt -g` 2. Send a message to the MQTT broker that's connected to your generated application. Run the following MQTT client command: `mqtt pub -t 'light/measured' -h 'test.mosquitto.org' -m '{"id": 1, "lumens": 3, "sentAt": "2017-06-07T12:34:32.000Z"}'` 3. Go back to the previous terminal to check if your application logged the streetlight condition you just sent. You should see something like this displayed in the terminal: `lightMeasured was received from mosquitto: { id: 1, lumens: 3, sentAt: '2017-06-07T12:34:32.000Z' } Streetlight with id "1" updated its lighting information to 3 lumens at 2017-06-07T12:34:32.000Z.` ## Summary In this tutorial, you learned how to create a Glee project from the [Streetlights API specification document created in a previous tutorial](https://asyncapi.com/docs/tutorials/create-asyncapi-document). Additionally, you've learned how to run your code by installing the project's dependencies and sending several test messages to the Streelights application using the MQTT client. ## Next steps Now that you've completed this tutorial, go ahead and learn how to [validate your AsyncAPI messages (events)](https://asyncapi.com/docs/tutorials/message-validation) through the message validation techniques supported by AsyncAPI. [Go BackCreate AsyncAPI document](/docs/tutorials/create-asyncapi-document) [Up NextValidate AsyncAPI document with Studio](/docs/tutorials/studio-document-validation) Was this helpful? Help us improve the docs by sharing your feedback. [Submit Feedback](https://github.com/asyncapi/website/issues/new?template=docs-feedback.yml&title=Docs%20Feedback%3A%20%2Fdocs%2Ftutorials%2Fgenerate-code&labels=%F0%9F%93%91%20docs) OR [Create Issue on GitHub](https://github.com/asyncapi/website/issues/new/choose)