Dependency injection in Nest.js

What is Dependency Injection (DI)? Dependency Injection (DI) is a software design pattern that allows separation of object dependencies and their initialization. In the context of Nest.js, DI enables easier dependency management, reducing class interdependence and increasing application modularity and testability. DI is a software pattern that is not only related to nest.js or node.js … Read more

Data validation in NestJS using “Pipe”

Introduction to Nest.js “Pipe” Pipes in NestJS are special components used to transform and validate data before it reaches the controller or controller methods. Pipes are useful when we want to ensure that the data we receive in API requests meets certain conditions or is transformed in a specific way. Nest.js comes with built-in pipes … Read more

Nest.js controllers

What are controllers? Controllers in Nest.js are classic TypeScript classes that are decorated with the @Controller() decorator. In such classes, methods corresponding to HTTP operations such as GET, POST, PUT, DELETE are defined, where each method within the controller is decorated with a corresponding HTTP decorator. Example of a simple controller:

In this example, … Read more

Introduction to Nest.js

What is Nest.js? Nest.js is a Node.js framework for creating server-side applications. It uses modular architecture, which means that the application is divided into modules, where each module groups related functionality, so that new functionalities can be easily added without disrupting the existing parts of the application. Nest.js uses the TypeScript language (although JavaScript can … Read more

Environment variables = ENV variable

What are environment variables Environment Variables (Environment Variables) are used in various places in software development and IT infrastructure, such as code: operating systems (“PATH” variable that defines the directories in which the operating system searches for executable files), software development (variables for storing configuration parameters such as API keys, databases, URLs..), security (for storing … Read more

Node starter project (TypeScript + Docker)

Project skeleton We will assume that the project will have several smaller projects, ie. container, e.g. a part for microservices, a part for working with the database… It is good to create subfolders in the root of the project for each smaller project, e.g.:

Creating package.json First we will create a package.json file in … Read more

Node.js Streams

What are Streams in Node.js? Streams allows for more efficient processing of large amounts of data, and can be viewed as a “river” of data. Streams “saves” memory because by processing data in chunks, working with large amounts of data does not occupy a large amount of memory at once. Streams processes data quickly, because … Read more

Node.js File system

Introduction Understanding the file system in Node.js is essential for developing applications that require reading, writing, and manipulating files. Node.js offers the fs module, which enables synchronous and asynchronous file management. This article explains in detail how to use the fs module in Node.js. fs module is part of the Node.js API that allows working … Read more

Node.js Buffers

What are Buffers? When working with data transmitted over a network or when reading and writing files on disk, we often encounter data that is not immediately available in its entirety. Buffers are temporary stores for data while it is being moved from one place to another. Buffers allow this data to be accumulated and … Read more

Node.js EventEmitter

Understanding EventEmitter in Node.js Node.js is a popular platform that allows building scalable applications through an asynchronous, event-driven approach. One of the key mechanisms that enables this approach is EventEmitter. To understand its importance and functionality, let’s think of EventEmitter as a hub for communication within a Node.js application, where events are sent, received and … Read more