🔐 Refresh/Access Token Authentication Demo with Client Side Rendering, Server Side Rendering and Websockets
Access/Refresh Token Authentication Demo with Node.js And Typescript
Watch the YouTube Tutorial
Backend: Node.js, Typescript, MongoDB, Kubernetes
Frontend: Next.js, Typescript
DevOps: Docker, Terraform, Kubernetes, Google Cloud
Requirements: Docker, Docker Compose, Yarn, Node.js
Optional: Terraform, Google Cloud SDK
Setup
make setup
http://localhost:3000
http://localhost:3000/github
GITHUB_CLIENT_ID
in .env.development
NEXT_PUBLIC_GITHUB_CLIENT_ID
in client/.env.development
GITHUB_CLIENT_SECRET
in .env.development
Development
make client
(Start Next.js development server, http://localhost:3000)make backend
(Start development backend services)Services
client
Next.js client (web application)api
Node.js server (http api)realtime
Node.js server (websocket server)shared
Typescript lib (shared code)infrastructure
Terraform (configurations to deploy application in the cloud)Commands
make init-infrastructure
(Initialize Terraform)make apply
(Apply cloud resources, ~15 minutes)make deploy
(Build and deploy services to Kubernetes cluster)make destroy
(Destroy cloud resources)make client-image
(Build and push client Docker image)make api-image
(Build and push api Docker image)make realtime-image
(Build and push Docker image)Step by step guide
Makefile
gcloud auth application-default login
make create-terraform-bucket
)terraform.backend.bucket
in infrastructure/main.tf to TF_BUCKET
https://api.${DOMAIN}/github
github_client_id
github_client_secret
refresh_token_secret
access_token_secret
mongodbatlas_public_key
mongodbatlas_private_key
atlas_project_id
(found under Settings)0.0.0.0/0
to your MongoDB Atlas project "IP Access List" (Under Network Access)make init-infrastructure
make deploy
main-zone
, copy the NS
record to your domain registrarmake apply
https://${DOMAIN}
make deploy