Posts

Showing posts with the label typescript

Deploying the NodeJS TypeScript Function to Google Cloud Function

Image
Introduction Google Cloud Functions (GCF) is a component of Google Cloud Platform (GCP) that allows you to deploy functions in a simple and flexible way. With a serverless approach, you can focus on developing your product without spending much time and effort managing infrastructure or cloud storage. I previously wrote about deploying a NodeJS TypeScript application to Google App Engine . Now, let's explore how Google Cloud Functions can help you deploy the necessary functions on-demand. GCF supports multiple runtime environments such as NodeJS , Golang , Python , Ruby , Java , and .NET . You can create a Cloud Function directly through the Google Cloud Console or via the Google Cloud CLI . In this article, I'll guide you through using the Google Cloud CLI to deploy a Cloud Function developed with NodeJS and TypeScript. Prerequisites Before we proceed, make sure you have the following: A Google Cloud account with Cloud Functions enabled Basic knowledge of NodeJS . ...

NodeJS Secure Environment Variables with Google Key Management Service

Image
Introduction When developing applications, using environment variables is essential. They help configure values for different environments like development, staging, and production. Some environment variables, such as API keys , database connections , or passwords , are sensitive and need to be kept secure. If you're using Google Cloud , their Key Management Service (KMS) can help you manage keys, and allows you to encrypt and decrypt values using those keys. Prerequisites Before we proceed, make sure you have: A Google Cloud account with permissions to use KMS . Google Cloud CLI installed . Basic knowledge of NodeJS . You can refer to this guide to set up a NodeJS TypeScript project , which will be used in this tutorial. Key Management Service KMS works with key rings, which hold multiple keys. You use these keys to encrypt and decrypt string values or file data. Be cautious: if a key is deleted, any data encrypted with it can't be decrypted anymore. To create a key ring,...

Uploading Files to Google Cloud Storage with NodeJS

Image
Introduction This guide will show you how to upload files to Google Cloud Storage using NodeJS . This method, which separates file storage from logic processing, is commonly used today. Cloud Storage offers an efficient solution for securely storing data, with major providers like Google , Amazon , and Azure leading the way. Prerequisites Before you proceed, make sure you have: A Google Cloud account or a Service Account with the necessary permissions to interact with a Bucket . Installed the Google Cloud CLI . Basic knowledge of NodeJS . You can refer to this guide to set up a NodeJS TypeScript project as used in this article . Creating a Service Account Refer to this guide to create a JSON file for your Service Account before moving on to the next steps. Setting roles for necessary permissions Ensure you have assigned the roles needed to interact with Google Bucket . gcloud projects add-iam-policy-binding {project id} \ --member=serviceAccount:{service account usern...

React Practice Series

Image
Introduction React is a JavaScript library created by Facebook , often referred to as the most popular frontend framework today. This page aims to gather articles related to ReactJS , covering topics such as theory, features, and commonly used packages in the process of building ReactJS applications. I will update this series with more articles in the future as new ideas for content come up. The articles are arranged in increasing order of difficulty, so if you have time, it's recommended to start from the beginning of the series. This will ensure you grasp the essential knowledge and information needed for the subsequent articles. Here are some key topics in the series that you need to explore to effectively use ReactJS : Fundamental : React Hook, React Context, Lazy load, etc. State management : redux, mobx, recoil, etc. Middleware libraries : redux-thunk, redux-saga, redux-observable, etc. Popular packages : react-query, immer, styled-components, etc. Rendering techniques : C...

NodeJS Practice Series

Image
Introduction NodeJS is an open-source and cross-platform JavaScript runtime environment . Here are some key points about NodeJS : V8 Engine : NodeJS runs on the V8 JavaScript engine , which is also the core of Google Chrome . This allows NodeJS to be highly performant. Asynchronous and Non-Blocking : NodeJS  uses an event-driven, non-blocking I/O model. It’s lightweight and efficient, making it ideal for data-intensive real-time applications. Single-Threaded : NodeJS  runs in a single process, handling multiple requests without creating new threads. It eliminates waiting and continues with the next request. Common Language : Frontend developers who write JavaScript for browsers can use the same language for server-side code in NodeJS . You can even use the latest ECMAScript standards without waiting for browser updates. This page is designed to compile articles related to NodeJS , including how to integrate it with various libraries and relevant tech stacks. I will cont...

Github CI/CD with Google Cloud Build

Image
Introduction Continuous Integration (CI) : This is the process of building, testing, and performing necessary actions to ensure code quality before it gets merged into the main branch for deployment. Continuous Delivery (CD) : This usually happens after CI and includes steps to deploy the source code to various environments like staging and production . This guide will show you how to set up CI/CD on Github using Google Cloud Build . While Github provides shared runners, if you or your organization have many jobs that need executing during development, setting up your own runner is a better choice. Before proceeding, you should understand some basics about Google Cloud Run to build and deploy Docker images. You can refer to this article for more details: Build Docker image for NodeJS Typescript Server . Setting Up GitHub CI/CD First, create a Github repository. You can choose either a public or private repository. You can use a NodeJS TypeScript application, following my guide o...

Using Google Cloud Run to Deploy Docker Image

Image
Introduction Google Cloud Run (GCR) makes deploying a Docker image as easy as running it locally. GCR also includes customizable configuration options for managing services, simplifying the deployment process significantly. Build Docker Image The key step in deploying with a Docker image is successfully building that image. In this guide, we’ll use a NodeJS server Docker image created in this article . Follow the steps to build your Docker image (or use an existing one), and push it to Google Artifact Registry before proceeding. Deploy Docker Image To deploy a Docker image using Google Cloud Run , simply use the following command: gcloud run deploy express-ts --image {docker image} --port {port container} --region {region id} --max-instances {number of instance} --allow-unauthenticated --image : is the link to the Docker image on Google Artifact Registry or Docker Hub --port : is the container port you are exposing --max-instances : is the number of instances...

Deploy NodeJS Typescript to Google App Engine

Image
Introduction In this guide, I will walk you through deploying a NodeJS Typescript application to Google App Engine (GAE) . GAE offers a straightforward and quick deployment process for various programming languages. If you're developing your NodeJS app using JavaScript , deploying it is pretty straightforward. However, if you're using Typescript , there's an extra step you'll need to take, which I'll explain here. Prerequisites Before we proceed, ensure you have the following: A Google Cloud account with Google App Engine enabled. The gcloud CLI installed. Creating a NodeJS Typescript Project First, create a file named ` src/main.ts ` with the following content: import express from 'express' const app = express () const port = 8080 app . get ( '/' , ( req , res ) => { res . send ( 'This is NodeJS Typescript Application! Current time is ' + Date . now ()) }) app . listen ( port , () => { console . log ( `Server is runn...