- Run
npm install
in./docker
. - Run
npm install
in./message-sender
. - Run
npm install
in./rest
.
- Run
npm run start:docker
to start RabbitMQ. - Run
npm run start:nest
to start the NestJS server. - In a new terminal, run
npm run start:sender
to start the CLI RabbitMQ message sender (a.k.a. the "Sender").
- Nest is opinionated on message shape (it needs the
data
property on the message). - Our platform currently has a property named
payload
instead ofdata
. So Nest says the message data isundefined
. - Reproduce:
- In the Sender terminal, type
works
and press return (this will send the data inmessage-sender/messages/works.json
). - In the NestJS terminal, you'll see the message. This is desired.
- In the Sender terminal, type
does-not-work
and press return (this will send the data inmessage-sender/messages/does-not-work.json
). - In the NestJS terminal, you'll see
undefined
.
- In the Sender terminal, type
- Add a way to transform our message shape into one Nest expects.
- Interceptors and pipes can't solve this problem, since
data
is extracted from the message before the interceptors or pipes are called.