Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Latest commit

 

History

History

simple-subscribe

Subscribe example

A basic example showing how to define an AsyncAPI channel as a subscribe operation, and how to use the generated library.

This example contains the following files:

  • asyncapi.json is the AsyncAPI document for the application that defines it as subscribe operation.
  • index.ts contains a usage example of the generated library that subscribe to the channel.
  • index.spec.ts test that the usage example (index.ts) has set up a correct subscription by publishing to the channel over NATS.
  • asyncapi-nats-client contains the generated client.

How to generate the client

To generate the client, run this command:

npm run generate:client

If you are on Windows, use the generate:client:windows script instead:

npm run generate:client:windows

How to test this example

To test this example use:

npm i && npm run test

If you are on Windows, use the test:windows script instead:

npm i && npm run test:windows

How to run this example

To run this example, use:

npm i && npm run start

If you are on Windows, use the start:windows script instead:

npm i && npm run start:windows

Afterwards, manually publish a message over NATS through external tooling.