Category: TypeScript


API with NestJS #153. SQL transactions with the Drizzle ORM

This entry is part 153 of 153 in the API with NestJS

Ensuring the integrity of the data is a fundamental responsibility of each developer. Fortunately, SQL databases give us the tools to ensure our database stays consistent and accurate. A crucial scenario to consider is when two SQL queries depend on each other. A typical example is transferring money between two bank accounts. Suppose we have […]


API with NestJS #152. SQL constraints with the Drizzle ORM

This entry is part 152 of 153 in the API with NestJS

When working with SQL databases, we can configure constraints to ensure our data does not get corrupted. In this article, we explore and implement different SQL constraints using PostgreSQL, NestJS, and the Drizzle ORM. Not-null constraint By default, SQL columns can hold nulls, representing an absence of value. We need the not-null constraint using the […]


API with NestJS #151. Implementing many-to-one relationships with Drizzle ORM

This entry is part 151 of 153 in the API with NestJS

Managing relationships between tables is a significant part of dealing with SQL databases. In this article, we continue learning to use Drizzle ORM with NestJS and implement many-to-one relationships. Check out this repository if you want to see the full code from this article. The many-to-one relationship With many-to-one relationships, a row from the first […]


API with NestJS #150. One-to-one relationships with the Drizzle ORM

This entry is part 150 of 153 in the API with NestJS

When building a database, the tables we set up often connect to each other. Managing these relationships is one of the crucial parts of working with databases. In the previous article, we learned how to use NestJS with Drizzle to set up a simple project with PostgreSQL. This time, we go further and write more […]

JavaScript NestJS

API with NestJS #148. Understanding the injection scopes

This entry is part 148 of 153 in the API with NestJS

When a NestJS application starts, it creates instances of various classes, such as controllers and services. By default, NestJS treats those classes as singletons, where a particular class has only one instance. NestJS then shares the single instance of each provider across the entire application’s lifetime, creating a singleton provider scope. If you want to […]


API with NestJS #145. Securing applications with Helmet

This entry is part 145 of 153 in the API with NestJS

Ensuring that our application is secure is one of the most important things we must do as developers. One of the ways to protect our application from well-known vulnerabilities is to set appropriate response headers. There are quite a lot of different security-related response headers to consider. Fortunately, the helmet library can set them for […]


API with NestJS #144. Creating CLI applications with the Nest Commander

This entry is part 144 of 153 in the API with NestJS

Command Line Applications are very useful for developers. We can interact with them by executing specific commands in the terminal, giving us much control and flexibility. You probably already interact with various CLI applications, such as Git or NPM. Interestingly, we can also use NestJS to create a Command Line Interface (CLI) application. In this […]