• Stars
    star
    131
  • Rank 275,867 (Top 6 %)
  • Language
    TypeScript
  • Created over 3 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ” Refresh/Access Token Authentication Demo with Client Side Rendering, Server Side Rendering and Websockets

Fullstack Authentication

Access/Refresh Token Authentication Demo with Node.js And Typescript

Watch the YouTube Tutorial

Stack

Backend: Node.js, Typescript, MongoDB, Kubernetes

Frontend: Next.js, Typescript

DevOps: Docker, Terraform, Kubernetes, Google Cloud

Usage

Requirements: Docker, Docker Compose, Yarn, Node.js

Optional: Terraform, Google Cloud SDK

Setup

  • make setup
  • Create GitHub OAuth app here
    • Set "Homepage URL" to http://localhost:3000
    • Set "Authorization callback URL" to http://localhost:3000/github
    • Set GITHUB_CLIENT_ID in .env.development
    • Set NEXT_PUBLIC_GITHUB_CLIENT_ID in client/.env.development
    • "Generate a new client secret"
    • Set GITHUB_CLIENT_SECRET in .env.development

Development

  • make client (Start Next.js development server, http://localhost:3000)
  • make backend (Start development backend services)

Codebase

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)

Deployment

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

  1. Configure variables in Makefile
    • GCP_PROJECT You can create a project here
    • TF_BUCKET Choose a unique bucket name for Terraform state
    • EMAIL Only used for generating SSL certificates
    • GKE_ZONE Choose a region or zone from this list for your Kubernetes cluster
    • DOMAIN
  2. Sign into your project gcloud auth application-default login
  3. Create the bucket for storing Terraform state (make create-terraform-bucket)
  4. Set terraform.backend.bucket in infrastructure/main.tf to TF_BUCKET
  5. Insert secrets into Google Cloud Secret Manager
    • GitHub OAuth (create here)
      • Set "Authorization callback URL" to https://api.${DOMAIN}/github
      • github_client_id
      • github_client_secret
    • Secrets (generate here)
      • refresh_token_secret
      • access_token_secret
    • MongoDB Atlas (create a free cluster here)
      • Navigate to Project Settings -> Access Manager -> API Keys -> Create API Key -> Select Project Owner
      • mongodbatlas_public_key
      • mongodbatlas_private_key
      • atlas_project_id (found under Settings)
  6. Add 0.0.0.0/0 to your MongoDB Atlas project "IP Access List" (Under Network Access)
  7. Enable Container Registry in your GCP console
  8. make init-infrastructure
  9. make deploy
  10. Go to Google Cloud DNS, main-zone, copy the NS record to your domain registrar
  11. Uncomment code block in infrastructure/modules/kubernetes-cert-manager/main.tf and run make apply
  12. The app should be live at https://${DOMAIN}
  • Every time you want to deploy changes, just run make deploy

More Repositories

1

davinci-resolve-linux

Setup Davinci Resolve on Linux an Fix Issues with Importing and Exporting Media
109
star
2

centsideas

πŸ’‘ Modern Fullstack Application for Sharing Fastlane Ideas
TypeScript
31
star
3

docker-typescript-debug

🐞 Example for Debugging Node.js + Typescript Running inside Docker Containers with Hot Reload
TypeScript
24
star
4

maizzle

Example for rendering beautiful emails with dynamic content using TailwindCSS
JavaScript
23
star
5

kafka

Realtime BTC and ETH Wallet Tracker with Node.js and Kafka
TypeScript
21
star
6

mongo-search

Fuzzy Text Search And Autocompletion With MongoDB And Node.js
TypeScript
20
star
7

obsidian-scroll-speed

Obsidian Plugin to Change Scroll Speed Inside Files
TypeScript
18
star
8

obsidian-plugin

How to create your own Obsidian plugin
TypeScript
17
star
9

docker-puppeteer-webgl

WebGL doesn't work with Docker and Puppeteer
Starlark
14
star
10

nextjs-bazel

Attempt to Build Next.js with Bazel 🌿 (still some issues)
Starlark
12
star
11

pass

πŸ”‘ Manage and Sync Your Passwords and One-Time-Passwords on Linux
Shell
10
star
12

git-gcrypt

Guide to using encrypted Git remotes with the help of git-remote-gcrypt
9
star
13

stackoverflow-lerna-monorepo-vscode-intellisense

Lerna Monorepo Example for StackOverflow Question by @Undistraction
JavaScript
8
star
14

meshlab-camera-transformation

Misplaced Cameras When Importing Into MeshLab
Python
7
star
15

node-integration-testing

πŸ§ͺ Example for Easy and Effective Integration Testing with Node.js and Docker
TypeScript
7
star
16

simple-event-sourcing-example

🚌 Small Node.js Application to Learn the Concepts of Event Sourcing
TypeScript
6
star
17

flolu.de

🏠 My personal website
TypeScript
5
star
18

stackoverflow-typescript-go-to-definition

πŸ‘‰ Example Repository for Stackoverflow Question about VSCode and Typescript
TypeScript
4
star
19

maizzle-node-example

πŸ“¨ Example for rendering beautiful emails with dynamic content
HTML
4
star
20

minimal-bazel-monorepo

A small example monorepo for learning Bazel basics
HTML
3
star
21

bazel-ts-project

Try to understand ts_project from rules_nodejs
Starlark
3
star
22

cheat-sheet

Shell
3
star
23

obsidian-plugin-tutorial

JavaScript
1
star
24

oop-sose2020

Objektorientiertes Programmieren Sommersemester 2020 FSU Jena
Java
1
star
25

threejs-noise-scaling

How to scale this noise shader with the object's size it is applied to?
JavaScript
1
star
26

mongodb-k8s-connection

Cannot connect to MongoDB ReplicaSet from within Kubernetes Cluster (ECONNREFUSED)
Starlark
1
star
27

meganero

TypeScript
1
star
28

bazel

🌿 Getting started with Bazel for absolute beginners
Starlark
1
star
29

fedora

My Personal Fedora Setup Script
Shell
1
star
30

bazel-config

Project to experiment with generating configurations and secrets with Bazel. Working example can be found here:
Starlark
1
star
31

texture-resizer

πŸ–ΌοΈ Python script for batch resizing quadratic textures
Python
1
star
32

elasticsearch-k8s-connection

Issue while connecting to Elasticsearch from inside Kubernetes cluster with Node.Js
Starlark
1
star
33

flolu

Bio
1
star