Category: TypeScript

NestJS SQL

API with NestJS #69. Database migrations with TypeORM

This entry is part 69 of 121 in the API with NestJS

When working with relational databases, we define the structure of the data rather strictly. For example, we need to specify the format of every table along with fields, relations, indexes, and other structures. By doing that, we also tell the database how to validate the incoming data. It is crucial to think about the structure […]

NestJS

API with NestJS #68. Interacting with the application through REPL

This entry is part 68 of 121 in the API with NestJS

The NestJS team officially announced NestJS 9 on July 8th. One of its features is Read-Eval-Print-Loop (REPL) implementation. It is an environment that allows us to interact with our NestJS application through the terminal. In this article, we go through how to set up REPL with NestJS. We also use features built into NodeJS to […]

NestJS

API with NestJS #67. Migrating to TypeORM 0.3

This entry is part 67 of 121 in the API with NestJS

For a long time, TypeORM seemed to have a reputation of being somewhat stagnant. Lately, they stepped up their game, though, and started releasing many new versions. When doing that, they introduced a large number of breaking changes. In this article, we go through the most significant differences between 0.2.x and 0.3.x versions so far […]

NestJS SQL

API with NestJS #65. Implementing soft deletes using MikroORM and filters

This entry is part 65 of 121 in the API with NestJS

In this article, we look into the filters feature and implement soft deletes. With them, we can mark an entity as deleted without removing it from the database permanently. You can get the code from this article in this repository. Introducing MikroORM filters We can provide various filters when querying data using functions such as […]

NestJS SQL

API with NestJS #64. Transactions with PostgreSQL and MikroORM

This entry is part 64 of 121 in the API with NestJS

One of the most important things to care about as a web developer is the integrity of the data. In this article, we learn what a transaction is and how it can help us ensure that our data is correct. The idea behind transactions A transaction is a set of instructions that either happens entirely […]

NestJS SQL

API with NestJS #63. Relationships with PostgreSQL and MikroORM

This entry is part 63 of 121 in the API with NestJS

A significant advantage of SQL databases is handling relationships between various tables. Since, in web applications, entities often relate to each other, designing relationships is a big part of working with SQL databases. In this article, we continue learning MikroORM and use it to form relationships. You can find the code from this article in […]

JavaScript NestJS

API with NestJS #62. Introduction to MikroORM with PostgreSQL

This entry is part 62 of 121 in the API with NestJS

So far, in this series, we’ve used a few different solutions for managing databases. To work with MongoDB, we’ve used Mongoose. To manage a PostgreSQL database, we’ve utilized TypeORM and Prisma. This article looks into another Object-relational mapping (ORM) library called MikroORM. By having a broad perspective on what’s available, we can choose the library […]

NestJS

API with NestJS #61. Dealing with circular dependencies

This entry is part 61 of 121 in the API with NestJS

We need to watch out for quite a few pitfalls when designing our architecture. One of them is the possibility of circular dependencies. In this article, we go through this concept in the context of Node.js modules and NestJS services. Circular dependencies in Node.js modules A circular dependency between Node.js modules happens when two files […]

NestJS

API with NestJS #60. The OpenAPI specification and Swagger

This entry is part 60 of 121 in the API with NestJS

Across this series, we emphasize code readability and maintainability. In part #52 of this course, we’ve gone through generating documentation with Compodoc and JSDoc. This time we look into the OpenAPI specification and the Swagger tool. You can check out an interactive demo prepared by the Swagger team. Introducing OpenAPI and Swagger With OpenAPI and […]