Demonstrates Dapr integration with NestJS
Install packages
npm i
Ensure Dapr Cli is installed. See https://docs.dapr.io/getting-started/install-dapr-cli/
winget install Dapr.CLI
# OR
brew install dapr/tap/dapr-cli
You can use Dapr locally or Docker compose using
dapr init
To use docker compose & Dapr
docker compose up
The ports are:
Service | Port |
---|---|
NestJS | 3000 |
Dapr (NodeJS) | 3001 |
Dapr Sidecar | 3500 |
npm run start:dapr
# OR
dapr run --app-id basics --app-protocol http --app-port 3001 --dapr-http-port 3500 npm run start
Invoke endpoint to publish message
curl -X POST localhost:3000/pubsub
Observe handler received message
Un-comment the BadRequestException
throw to simulate handler failure
Observe retries defined in the resilience policy
Invoke the counter endpoint to increment the counter
curl -X POST localhost:3000/counter/counter-1/increment
Observe the counter value
curl localhost:3000/counter/counter-1
Observer the global counter value
curl localhost:3000/counter/global