Skip to content

TypeScript codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

Notifications You must be signed in to change notification settings

marcusmonteirodesouza/typescript-firestore-terraform-realworld-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RealWorld Example App

TypeScript codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

This codebase was created to demonstrate a fully fledged backend application built with TypeScript including CRUD operations, authentication, routing, pagination, and more.

We've gone to great lengths to adhere to the TypeScript community styleguides & best practices.

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

How it works

This is an Express.js based web-application, written in TypeScript, that implements the RealWorld API endpoints.

It depends on Firestore, a Serverless document database available on Google Cloud. Hence, this app can only be deployed on the Google Cloud platform.

System Design

system Design Diagram

Getting started

  1. Install Node.js and npm.
  2. Install Docker.
  3. Run npm start.

Testing

  1. Run npm test.

Deployment

Bootstrap

This process creates the projects, creates the Artifact Registry repository (in the Bootstrap project), enables the Cloud Build API, grants the iam.securityAdmin to the Cloud Build Service Account, sets up the Build Pipeline in the development project and the Deployment pipeline in the production project.

  1. Create an Organization on Google Cloud.
  2. Create a Folder on your Organization to create your projects in.
  3. Create a Billing Account.
  4. Install terraform.
  5. Install the gcloud CLI.
  6. Run gcloud auth login.
  7. Run gcloud auth application-default login.
  8. Make sure you own a domain name and have access to it's DNS configuration. This will be necessary to enable HTTPS.
  9. cd into the deployment/google-cloud/terraform/bootstrap.
  10. Comment out the entire contents of the backend.tf file.
  11. Create a terraform.tfvars file and add your variables' values.
  12. Run terraform init.
  13. Run terraform apply -target=module.bootstrap_project.google_project_service.enable_apis.
  14. Wait a few minutes until the APIs are enabled.
  15. Run terraform apply -target=module.bootstrap_project.
  16. Uncomment the backend.tf file's contents and update the bucket argument to the value of the tfstate_bucket output.
  17. Run terraform init and type yes.
  18. Run terraform apply -target=module.project.
  19. Manually connect the Github repositories via the console in CloudBuild. Do not create a Trigger, just click DONE once the repository is connected.
  20. Run terraform apply.

Build

  1. A Cloud Build shoud run to build and push a container image to Artifact Registry everytime you push a commit to the branch corresponding to the value you set for the github_repo_branch variable.
  2. It will also deploy the system into a "Development" environment.
  3. After the system is deployed, set up HTTPS for the created Load Balancers.

Build Pipeline

Tag and Deployment

  1. Create a Release on Github and tag the commit with a value matching the regex you used as the value of the github_repo_commit_tag variable.
  2. This will run the Tag pipeline to tag the artifacts.
  3. It will also trigger a Deployment to Production.

Tag Pipeline

Deployment Pipeline

About

TypeScript codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages