Nestjs Debezium example using postgres
To get a local copy up and running, please follow these simple steps.
Here is what you need.
- Node.js (Version: >= 20.x)
- docker, docker-compose (Version: >= 26.x, 2.x)
- npm
-
Setup Node If your Node version does not meet the project's requirements as instructed by the docs, either manually or using a tool like nvm or volta (recommended)
-
Clone the repo
git clone git@github.com:yadav-saurabh/nestjs-debezium.git
-
Go to the project folder
cd nestjs-debezium
-
Install packages with yarn
npm i
-
Set up your
.env
file- Duplicate
.env.example
to.env
- Configure environment variables in the
.env
file. Replace the placeholder values with their applicable values
- Duplicate
-
Run docker compose to get all the services up and running
docker-compose --env-file .env -f ./infra/compose.yaml up
-
Create connector (user connector)
-
from the debezium ui
http://localhost:8080/
-
from the cli using curl
# load the env source .env # create a connector (user-connector) for table user curl --location 'http://localhost:8083/connectors' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data '{ "name": "user-connector", "config": { "connector.class": "io.debezium.connector.postgresql.PostgresConnector", "database.hostname": "nestjs-debezium-postgres", "database.port": "5432", "database.user": "'$DB_USERNAME'", "database.password": "'$DB_PASSWORD'", "database.dbname": "'$DB_DATABASE'", "table.include.list": "public.user", "topic.prefix": "'$KAFKA_TOPIC_PREFIX'" } }'
-
-
Run nestjs server
npm run dev
POST /api/users
:- create a new userPATCH /api/users
:- update a userGET /api/users
:- get all usersGET /api/users/:id
:- get a usersDELETE /api/users/:id
:- get a users
GET /cdc/connectors
:- get all connectorsPUT /cdc/pause
:- pause a connectorsPUT /cdc/resume
:- resume a connectors