Express JavaScript

TypeScript Express tutorial #5. MongoDB relationships between documents

This entry is part 5 of 15 in the TypeScript Express tutorial

Today we dive into MongoDB relationships between documents. To do it we use Mongoose and the populate feature. As always, the code that we cover here is available in the express-typescript repository. You’re welcome to give it a star. MongoDB relationships between documents The fact is that MongoDB is a NoSQL database. It means that it […]

Express JavaScript

TypeScript Express tutorial #4. Registering users and authenticating with JWT

This entry is part 4 of 15 in the TypeScript Express tutorial

Today we cover an essential part of almost every application: registering users and authenticating them. To implement it, we use JSON Web Tokens (JWT). Instead of getting help from libraries like Passport, we build everything from the ground up to get the best understanding of how it works. As always, all of the code is […]

Express JavaScript

TypeScript Express tutorial #3. Error handling and validating incoming data

This entry is part 3 of 15 in the TypeScript Express tutorial

Since not always everything goes perfectly, you need to expect the unexpected. To prepare for that, we cover TypeScript Express error handling and incoming data validation. Just as before, the repository for the tutorial is mwanago/express-typescript. If you find it helpful, feel free to give it a star. Express Error handling In the previous part of the […]

JavaScript

Using recursion to traverse data structures. Execution context and the call stack

Hello! Today we tackle a very interesting topic, which is recursion. The article describes its main principles and dives deeper to uncover how does it work under the hood of the language, covering execution context and the call stack. Let’s go! JavaScript recursion Recursion An act of a function calling itself. Recursion is used to solve […]

JavaScript

Is eval evil? Just In Time (JIT) compiling

There is a high chance that you’ve stumbled across the JavaScript eval function.  It is a common knowledge that in JavaScript, eval is something that is a bad practice. Have you ever wondered how it works and why exactly a lot of people discourage it? This article covers that and presents some real-life usage of the eval […]

JavaScript

Handling errors in JavaScript with try…catch and finally

Mistakes happen. That’s a given. According to Murphy’s law, whatever can go wrong, will go wrong. Your job, as a programmer, is to be prepared for that fact. You have a set of tools that are prepared to do precisely that. In this article, we go through them and explain how they work. An error […]

JavaScript

Cross-Origin Resource Sharing. Avoiding Access-Control-Allow-Origin CORS error

In this article, we explain what Cross-Origin Resource Sharing (CORS) is and how to avoid errors associated with it and the Access-Control-Allow-Origin header. This includes describing it both from the viewpoint of the frontend and the backend. CORS: Cross-Origin Resource Sharing Cross-Origin Resource Sharing (CORS) is a mechanism allowing (or disallowing) the resources to be […]

JavaScript

Comparing working with JSON using the XHR and the Fetch API

Nowadays, JavaScript is often used to make Ajax requests. There are a lot of libraries that can do that for us, for example, axios or jQuery. Both of them use XMLHttpRequest (XHR). It differs from the relatively new Fetch API that was introduced a few years ago. This article explains both of them and points out their […]