Category: JavaScript

React

Dynamic and recursive forms with Formik and TypeScript

Formik is a popular tool that helps us write React forms and keep their code consistent across even big projects. Besides having a fixed number of properties, we sometimes need to allow the user to shape the form to some extent and create recursive data structures. In this article, we learn how to do that […]

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

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

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