This is a simple demo Node.js API that receives a POST request on the /accounts route and produces a message to the account-created topic.
There is also a consumer API that subscribes to this topic and publishes this message to the discord group via webhook.
First of all, clone this repo
:
git clone [email protected]:leonardopliski/node-apache-kafka.git
Move to the project dir:
cd node-apache-kafka/
Set the discord webhook environment variable: DISCORD_WEBHOOK_URL
export DISCORD_WEBHOOK_URL=<your-webhook-url-right-here>
With NVM run:
nvm use
With NPM run:
npm install
With Docker Compose installed just run:
npm run up
Start the main API.
npm run start:server
Start the subscriber API.
npm run start:consumer
Done! Execute a POST request to the following URL:
http://localhost:5050/accounts
body: {
"email": "[email protected]"
}
A message should appear on the Discord group.
- Kafka
- ZooKeeper
- Axios
- Node.js
- NVM
- Express
- Nodemon