No description
  • JavaScript 81.5%
  • HTML 12%
  • Dockerfile 6.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2024-02-11 21:16:01 +01:00
.vscode Add Dockerfile for all services 2020-11-16 14:17:35 +01:00
client fix: Update URLs to services in client and servers 2020-11-20 08:37:27 +01:00
infra/k8s fix: Update URLs to services in client and servers 2020-11-20 08:37:27 +01:00
nginx feat: Add nginx proxy 2020-11-16 22:49:01 +01:00
services fix: Update URLs to services in client and servers 2020-11-20 08:37:27 +01:00
.gitignore Scaffold project 2020-11-14 13:02:11 +01:00
.prettierrc Add Dockerfile for all services 2020-11-16 14:17:35 +01:00
docker-compose.yml feat: Add nginx proxy 2020-11-16 22:49:01 +01:00
LICENSE Update LICENSE 2024-02-11 21:16:01 +01:00
README.md Update README 2020-11-28 23:24:44 +01:00
skaffold.yml Add skaffold config file 2020-11-20 11:10:10 +01:00

Microservices: Blog

Quick start

Requirements: minikube (local Kubernetes)

  1. Clone this repository
  2. Start local kubernetes cluster: minikube start
  3. Apply configuration files:
    cd infra/k8s
    kubectl apply -f .
    
  4. Point your ingress hostname towards your minikube IP in hosts file: echo "$(echo | minikube ip)" "$(echo "blog.io")" >> /etc/hosts
  5. Access to app @ http://blog.io

Services

See config.js.

Service Port
posts 4000
comments 4001
query 4002
moderation 4003
even-bus 4005

Posts

Path Method Request Body Feature Result
/posts POST { title: string} Create a new post 201, created post object
/posts GET - Get all posts 200, list of posts
/events POST event object Does nothing 204

Comments

Path Method Request Body Feature Result
/posts/:id/comments POST { content: string } Create a new comment 201, comment object created
/posts/:id/comments GET - Get all comments 200, list of comments
/events POST event object Does nothing 204

Event bus

Path Method Request Body Feature Result
/events POST event = {type, data} Echo event to other services 200

Query

Aggregates posts and comments to be able to reduce to 1 the number of requests necessary to fetch all posts & requests.

Path Method Request Body Feature Result
/events POST event object Add post or comment to its local memory 200, post/comment object created
/posts GET - Get all posts & comments 200, list of posts & comments

Moderation

Updates status (approved or denied) of created comments depending on wether they include the FORBIDDEN word.

Path Method Request Body Feature Result
/events POST COMMENT_CREATED event object Updates status of comment and emits COMMENT_UTPDATED event 204

Architecture/Implementation

  • Front end: React based
  • Services: Express based (router + feature logic). No data persistence/DB. Data stored in servers' memory.
  • Deployment: kubernetes

Resources

Stephen Grider udemy's course on Microservices with Node JS and React