Skip to content

Latest commit

 

History

History
84 lines (56 loc) · 1.31 KB

README.md

File metadata and controls

84 lines (56 loc) · 1.31 KB

Basics: nest-dapr example

Demonstrates Dapr integration with NestJS

Getting Started

Install packages

npm i

Dapr Setup

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

Run the application

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

PubSub test

Invoke endpoint to publish message

curl -X POST localhost:3000/pubsub

Observe handler received message

Resiliency

Un-comment the BadRequestException throw to simulate handler failure

Observe retries defined in the resilience policy

Actor test

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