Skip to content

muhhylmi/express-mongoclient

Repository files navigation

This NodeJs Rest API Repository

this is NodeJs Rest API with postgres as primary database, in this repo express framework used to build the Rest API. and sequelize is used to build database model and migration.

whats implemented in this repo

  1. Rest API
  2. Messaging using Kafka
  3. Combine producer and consumer as one App
  4. Combine postgres and mongodb as one App (postgres as primary database and mongodb for receive event data from kafka)

Messaging Workflow

sequenceDiagram
    User->>API: hit API create note
    API->>Postgres: save note
    API->>Kafka: prduce event
    Kafka->>MongoDB: save note 
    Postgres-->>API: response succes/failed
    alt succes save mongo
        Kafka-->>API: Commit event
    else failed save mongo
        Kafka-->>API: Un Commit event
    end
    API-->>User:response message
Loading

How to Run App (install dependencies / prequisites)

  1. npm init
  1. npm add -D typescript ts-node @types/node @types/express nodemon
  1. ./node_modules/.bin/tsc --init
  1. "outDir": "./build"
  1. add script tsc :dev "tsc && nodemon ./build/index.js"

How to RUN APP

  1. npm install
  2. npm run tsc:dev