https://github.com/pactflow/example-consumer-js-kafka
Example NodeJS Kafka Consumer
https://github.com/pactflow/example-consumer-js-kafka
example
Last synced: 10 months ago
JSON representation
Example NodeJS Kafka Consumer
- Host: GitHub
- URL: https://github.com/pactflow/example-consumer-js-kafka
- Owner: pactflow
- License: mit
- Created: 2020-06-10T07:05:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-04-14T20:22:19.000Z (10 months ago)
- Last Synced: 2025-04-15T06:48:11.288Z (10 months ago)
- Topics: example
- Language: JavaScript
- Size: 837 KB
- Stars: 3
- Watchers: 11
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Example Node Kafka Consumer

[](https://testdemo.pactflow.io/overview/provider/pactflow-example-provider-java-kafka/consumer/pactflow-example-consumer-js-kafka)
[](https://testdemo.pactflow.io/pacts/provider/pactflow-example-provider-java-kafka/consumer/pactflow-example-consumer-js-kafka/latest) (latest pact)
[](https://testdemo.pactflow.io/pacts/provider/pactflow-example-provider-java-kafka/consumer/pactflow-example-consumer-js-kafka/latest/master) (master/master pact)
This is an example of a Node kafka consumer that uses Pact, [PactFlow](https://pactflow.io) and GitHub Actions to ensure that it is compatible with the expectations its consumers have of it.
The project uses a Makefile to simulate a very simple build pipeline with two stages - test and deploy.
See the canonical consumer example here: https://github.com/pactflow/example-consumer
See also the full [PactFlow CI/CD Workshop](https://docs.pactflow.io/docs/workshops/ci-cd) for which this can be substituted in as the "consumer".
In the following diagram, we'll be testing the "Product API", a simple HTTP service that exposes product information as a REST API, which is fed events from an Event API on the `product` topic.

## Pre-requisites
**Software**:
https://docs.pactflow.io/docs/workshops/ci-cd/set-up-ci/prerequisites/
## Usage
* Install the project: `make install`
* `npm install`
* Running the API locally: `make start`
* `docker-compose -f kafka-cluster.yml up -d --no-recreate`
* `npm run start`
* Producing test events into the `product` topic: `make test-events`
* `npm run test:events`
* Retrieve latest products: `curl localhost:8080/products`