API Design
REST, validation, OpenAPI/Swagger, DTOs, versioning, error handling
17 articles
Implementing Idempotency in NestJS with an Interceptor
When building APIs, especially for payments or operations that modify state, you want to avoid executing the same request multiple times if the client retries.…
Rate limiting using Throttler
When building a REST API, we must prepare for various cases. At first, everything might run smoothly, but as our API gains traction, we might encounter some…
Avoiding storing sensitive information in API logs
In previous parts of this series, we’ve learned how to implement logging in our REST API. Logs play an important role in debugging and maintaining reliable…
Uploading and streaming videos
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…
CORS – Cross-Origin Resource Sharing
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…
REST API versioning
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…
Modifying data using PUT and PATCH methods with Prisma
Developing a REST API requires us to create endpoints using various HTTP methods such as GET, POST, and DELETE. People utilizing our API expect that making a…
Logging with the built-in logger when using raw SQL
Troubleshooting a deployed application can be challenging. We can’t use the debugger and stop an application used by other people. Instead, we need to…
Updating entities with PUT and PATCH using raw SQL queries
A significant thing to realize when developing a REST API is that HTTP methods are a matter of convention. For example, in theory, we could delete entities…
The OpenAPI specification and Swagger
Across this series, we emphasize code readability and maintainability. In part #52 of this course, we’ve gone through generating documentation with Compodoc…
Using ETag to implement cache and save bandwidth
We’ve introduced various ways of caching files on the server throughout this series. This article teaches how to help the browser perform caching on the client…
Uploading files to the server
So far, in this series, we’ve described two ways of storing files on a server. In the 10th article, we’ve uploaded files to Amazon S3. While it is very…
Updating with PUT and PATCH with MongoDB and Mongoose
When we develop a REST API, there is a set of HTTP methods that we can choose from, such as GET, POST, and DELETE. A crucial thing to understand is that HTTP…
Reacting to Stripe events with webhooks
So far, in this series, we’ve interacted with Stripe by sending requests. It was either by requesting the Stripe API directly on the frontend, or the backend.…
Sending scheduled emails with cron and Nodemailer
So far, in this series, we’ve been creating an API that allows users to interact with our application. As soon as the client makes the request, we react to it…
Serializing the response with interceptors
Sometimes we need to perform additional operations on the outcoming data. We might not want to expose specific properties or modify the response in some other…
Error handling and data validation
NestJS shines when it comes to handling errors and validating data. A lot of that is thanks to using decorators. In this article, we go through features that…