Category: NestJS

NestJS SQL

API with NestJS #125. Offset and keyset pagination with Kysely

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

So far, when working with Kysely, we fetched all rows from our tables. However, this might not be the best solution when it comes to performance. A common approach is to query the data in parts and present the users with separate pages or infinite scrolling. We implement pagination in this article with NestJS, PostgreSQL, […]

NestJS SQL

API with NestJS #124. Handling SQL constraints with Kysely

This entry is part 124 of 125 in the API with NestJS

When using SQL databases, we can set constraints to ensure our data remains accurate and reliable during insertions, updates, or deletions. In this article, we’ll explore different SQL constraints and demonstrate how to apply them using Kysely and NestJS to maintain data integrity. Check out this repository for the full code from this article. Not-null […]

NestJS SQL

API with NestJS #123. SQL transactions with Kysely

This entry is part 123 of 125 in the API with NestJS

The integrity of our data should be one of the primary concerns of web developers. Thankfully, SQL databases equip us with tools that we can use to ensure the consistency and accuracy of our data. You can see the complete code from this article in this repository. One of the critical situations to consider is […]

NestJS SQL

API with NestJS #122. Many-to-many relationships with Kysely and PostgreSQL

This entry is part 122 of 125 in the API with NestJS

Implementing relationships across tables is a crucial aspect of working with SQL databases. So far, this series covers using Kysely to design simple relationships such as one-to-one and many-to-one. This article looks into many-to-many, which is a slightly more advanced relationship. Check out this repository if you want to see the full code from this […]

NestJS SQL

API with NestJS #119. Type-safe SQL queries with Kysely and PostgreSQL

This entry is part 119 of 125 in the API with NestJS

Object-Relational Mapping (ORM) libraries such as Prisma and TypeORM can help us produce code faster by avoiding writing SQL queries. They have a smaller learning curve because we don’t need to learn a new language and dive deep into understanding how the database works. Unfortunately, ORM libraries often generate SQL queries that are far from […]

NestJS

API with NestJS #118. Uploading and streaming videos

This entry is part 118 of 125 in the API with NestJS

Nowadays, video streaming is one of the main ways of consuming and sharing content. In this article, we explore the fundamental concepts of building a REST API for uploading videos to the server and streaming them using NestJS and Prisma. Check out this repository if you want to see the full code from this article. […]

NestJS Security

API with NestJS #117. CORS – Cross-Origin Resource Sharing

This entry is part 117 of 125 in the API with NestJS

Cross-Origin Resource Sharing (CORS) is a mechanism for disallowing or allowing resources to be requested from another origin. It is built into web browsers and determines whether it is safe to allow a cross-origin request based on HTTP headers. In this article, we explain the CORS mechanism and use it with a NestJS application. What […]

NestJS

API with NestJS #116. REST API versioning

This entry is part 116 of 125 in the API with NestJS

The requirements of web applications constantly evolve, and so do the REST APIs they use. With the rise of the popularity of distributed systems and microservices, maintaining backward compatibility is increasingly important. Even if we maintain a monolithic architecture, there is a good chance that our frontend has a separate deployment pipeline. In this article, […]

NestJS SQL

API with NestJS #115. Database migrations with Prisma

This entry is part 115 of 125 in the API with NestJS

One of the characteristics of relational databases is a strict data structure. We need to specify the shape of every table with its fields, indexes, and relationships. Even if we design our database carefully, the requirements that our application must meet are changing. Because of that, our database needs to evolve as well. When restructuring […]