Category: NestJS

NestJS SQL

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

This entry is part 119 of 121 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 121 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 121 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 121 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 121 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 […]

JavaScript NestJS

API with NestJS #113. Logging with Prisma

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

Using a debugger with an application running locally on our machine is a great way to troubleshoot. Unfortunately, we can’t do that with a deployed app. To be able to investigate any potential issues, we need to implement a logging functionality. In this article, we use the logger built into NestJS and integrate it with […]

JavaScript NestJS

API with NestJS #112. Serializing the response with Prisma

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

When fetching data from the database, we do not always want to present it to the user in the original form. When working with NestJS, the most popular way of modifying the response is with the library. However, using the above library with Prisma requires a bit of work. In this article, we provide […]

NestJS SQL

API with NestJS #111. Constraints with PostgreSQL and Prisma

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

One of the most important aspects of working with a database is ensuring the stored information is correct. One of the fundamental ways of doing that is by using the correct data types for the columns in our tables. Thanks to that, we can make sure that a particular column holds only numbers, for example. […]