Skip to content

Commit

Permalink
adds the manual installation
Browse files Browse the repository at this point in the history
  • Loading branch information
afzal442 committed Sep 19, 2023
1 parent 0a78b28 commit 1017fe5
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 27 deletions.
86 changes: 86 additions & 0 deletions docs/pages/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ weight: 30

Before installing Glee into your project, make sure you have pre-installed NPM, NodeJs and [AsyncAPI CLI](https://github.com/asyncapi/cli) tools on your system.

### Automatic Installation

The best way to get started with Glee is by using AsyncAPI CLI, which sets up everything automatically for you.
To create a project, run:

Expand All @@ -31,3 +33,87 @@ Also, you can already open the project in your favorite editor and start tweakin
```

While making twists to your application, you can follow along with our getting started guide on the relevant page.

### Manual Installation

To manually create a new app, create a folder e.g. `myapp` and install the required packages:

```js
npm init -y
npm install @asyncapi/glee
```

Open your package.json file and add the following scripts:

```js
{
"scripts": {
"docs": "glee docs",
"dev": "glee dev",
"start": "glee start",
}
}
```

These scripts refer to the different stages of developing an application.

- `glee docs`: This script generates documentation for your project using the "Glee" documentation tool. This documentation includes information about your project's APIs, modules, and usage instructions.

- `glee dev`: This script is used for starting a development server. It launches a local development server, build your project in development mode, or perform other development-related tasks.

- `glee start`: This script is responsible for starting your project or application. It is used to launch a production-ready server or application instance.

#### Creating `asyncapi.yaml` file and other required directories

Create a yaml file that supports capable of receiving a "hello {name}" message with the protocol as `ws` and the channel name as `hello` the hello API will subscribe to. The operationId property is `onHello` that's the name of function and the payload property is type string publishing to that channel.

```yaml
asyncapi: 2.6.0
info:
title: Hello, Glee!
version: 0.1.0

servers:
websockets:
url: ws://0.0.0.0:3000
protocol: ws

channels:
hello:
publish:
operationId: onHello
message:
$ref: '#/components/messages/hello'
subscribe:
message:
$ref: '#/components/messages/hello'

components:
messages:
hello:
payload:
type: string
```
Create an operation function `onHello.js` inside `myapp/functions`:

```js
export default async function (event) {
return {
reply: [{
payload: `Hello from Glee! You said: "${event.payload}".`
}]
}
}

```
Finally, create a `.env` file specifying a server name:

```
GLEE_SERVER_NAMES=websockets
```

#### Run the Development Server

- Run `npm run dev` to start the development server.
- Connect to `ws://localhost:3000/hello` and send a WebSocket request with a payload e.g. {"john"}
27 changes: 0 additions & 27 deletions docs/pages/usage.md

This file was deleted.

0 comments on commit 1017fe5

Please sign in to comment.