Posts

NestJS Basic Concepts (V10.X)

Image
 Main Building Blocks Controller - Handle incoming request Services - Handle business logic Modules - Group together everything Pipes - Validate incoming data Filters - Handle incoming errors Guards - Handle authentication Interceptors - Adding extra data to incoming request or to response Repositories - Handle data stored in DB Nest does not handle HTTP request itself. We need to provide either Express or Fastify for handling HTTP requests. By default, Nest uses Express, Nest main libraries, " @nestjs/common " : Functions, Classes which are mainly use in Nest " @nestjs/core " : " @nestjs/platform-express " : Express adaptor to handle HTTP requests " reflect-metadata " : To use of JavaScript Decorator feature " typescript " : TypeScript tsconfig ,  both decorator lines are important to make nest working properly, { " compilerOptions " : { " module " : " CommonJS " , " target " :

Kubernetes for Micro Services

Image
(Special thanks to Stephen Grider) Cluster - Whole wrapper Node - A virtual machine Pod - Container wrapper. There can be multiple containers inside a Pod Deployment - Monitor set of Pods. If something down, then this will restart them to make sure it is running Service - Provide nice URLs for containers How to create a Pod directly? Create Pod using configuration file - kubectl apply -f posts.yml  Note: This apply use for any type of cluster change Example of posts.yml apiVersion : v1 kind : Pod metadata : name : posts spec : containers : - name : post image : dilumdarshana/posts:0.0.1 Get all pods running - kubectl get pods Delete Pods -  kubectl delete -f posts.yml General important Pod commands: kubectl exec -it <pod name> <command> kubectl logs <pod name> kubectl delete pod <pod name> kubectl describe pod <pod name> How to create Pods via deployment ? kubectl apply -f <deployement.yml> Example of deployment.yml apiVersion : apps/v1