No description
- JavaScript 81.5%
- HTML 12%
- Dockerfile 6.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .vscode | ||
| client | ||
| infra/k8s | ||
| nginx | ||
| services | ||
| .gitignore | ||
| .prettierrc | ||
| docker-compose.yml | ||
| LICENSE | ||
| README.md | ||
| skaffold.yml | ||
Microservices: Blog
Quick start
Requirements: minikube (local Kubernetes)
- Clone this repository
- Start local kubernetes cluster:
minikube start - Apply configuration files:
cd infra/k8s kubectl apply -f . - Point your ingress hostname towards your minikube IP in hosts file:
echo "$(echo | minikube ip)" "$(echo "blog.io")" >> /etc/hosts - 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