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.
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
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
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.