JavaScript React

Using AbortController to deal with race conditions in React

When developing applications, data fetching is one of the most fundamental tasks. Despite that, there are some things to watch out for: one of them is race conditions. This article explains what they are and provides a solution using the AbortController. Identifying a race condition A “race condition” is when our application depends on a […]

Security

The Referer header and the importance of the Referrer-Policy

As web developers, we should care about the privacy of our users. This article explains what the Referer header is and what information it exposes. We also learn to use the Referrer-Policy to control how many details the referer header should include. We can increase privacy and deal with some potential security issues by doing […]

Security

The danger of iframe clickjacking and how to deal with it

When developing an application, we need to ensure that our users are safe from various attacks. Unfortunately, the web has a lot of mechanisms that can be abused. In this article, we explore the idea of iframes and underline the danger of clickjacking. We also learn how to deal with this problem using the X-Frame-Options […]

JavaScript

Countering MIME sniffing with X-Content-Type-Options and Content-Type headers

We’ve learned how to block certain cross-site-scripting (XSS) attacks in the previous article. We did that by disallowing our website from running JavaScript from unknown origins. Unfortunately, attackers might be able to upload malicious code into our application disguised as an image, for example. Then, they can take advantage of MIME sniffing to trick a […]

JavaScript

Fighting cross-site-scripting (XSS) with content security policy

The security of our web application should be one of our primary concerns as developers. One of the threats we need to consider is cross-site scripting (XSS). This article explains the danger it poses and how we can fight it using a Content Security Policy (CSP) header. Cross-Site Scripting (XSS) With cross-site scripting (XSS) attacks, […]

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 […]

Node.js SQL

Serial type versus identity columns in PostgreSQL and TypeORM

So far on this blog, we’ve used the serial type to define autoincrementing ids for our tables. However, TypeORM started fully supporting identity columns very recently. Since PostgreSQL official recommends using them, it is a good moment to go through both approaches and compare them. Serial type The serial data type allows us to generate unique […]

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 […]