Posts

Showing posts with the label javascript

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...

Using PureComponent and React.memo to improve Performance in React

Image
Introduction PureComponent in React is built on the concept of Pure Function. In this article, let's dive into PureComponent and the memo hook in React, as well as how to apply these tools to improve performance in React applications. What is a Pure Function? First off, it's important to understand the concept of a Pure Function, which will always return the same result with the same input parameters. To put it simply, the same input will always yield the same output. For example: // this is pure function function sum ( a : number , b : number ): number { return a + b ; } sum ( 1 , 2 ); // always return 3 const offset = 3 ; // this is not pure function function sumWithOffset ( a : number , b : number ): number { return a + b + offset ; } sum ( 1 , 2 ); // result depend on offset value What is a Pure Component? In React, a PureComponent is considered a component that only renders when there's a change in props or state, where the change in props or state is det...

Sitemap

Image
A page aggregator designed for easy reference and search, compiling all blog posts for convenient access.

Constants, Object.freeze, Object.seal and Immutable in JavaScript

Image
Introduction In this article, we're diving into Immutable and Mutable in JavaScript, while also exploring how functions like Object.freeze() and Object.seal() relate to Immutable . This is a pretty important topic that can be super helpful in projects with complex codebase. So, what's Immutable? Immutable is like a property of data in JavaScript. It means once the data is created, it can't be changed. This allows for better memory management and catching changes promptly. This is a big deal and totally contrasts with Mutable, which is the default nature when you initialize data in JavaScript. Implementing Immutable in a project makes development much smoother, reduces issues that crop up, and saves a ton of effort and time for maintenance down the road. But what happens if you don't use Immutable? Let me give you an example of how changing data during development can lead to some serious issues. let info = { name: "name" , address: "addres...