Category: TypeScript

JavaScript SQL TypeScript

Managing date and time with PostgreSQL and TypeORM

While dealing with data, we often have to handle the date and the time. When doing so, there are quite a few things to consider. In this article, we approach various issues both from the standpoint of PostgreSQL and TypeORM. Ways to store and display date and time in PostgreSQL By default, Postgres represents dates […]

JavaScript NestJS TypeScript

API with NestJS #31. Two-factor authentication

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

While developing our application, security should be one of our main concerns. One of the ways we can improve it is by implementing a two-factor authentication mechanism. This article goes through its principles and puts them into practice with NestJS and Google Authenticator. Adding two-factor authentication The core idea behind two-factor authentication is to confirm […]

JavaScript NestJS TypeScript

API with NestJS #30. Scalar types in GraphQL

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

With GraphQL, we model our API as a graph. Within a schema, we have various types of nodes that can relate to each other. While the fields in our query might have sub-fields, at some point, we want to work on concrete data. We refer to the type that describes an individual value as the […]

JavaScript NestJS TypeScript

API with NestJS #29. Real-time updates with GraphQL subscriptions

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

So far, in this series, we’ve used GraphQL both to fetch and modify data. While this covers many real-life cases, modern applications often include situations in which users need immediate feedback when some event occurs. One of the solutions suggested by the GraphQL team is polling. In this technique, the client periodically requests the API for […]

JavaScript NestJS TypeScript

API with NestJS #27. Introduction to GraphQL. Queries, mutations, and authentication

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

GraphQL has gained quite a lot of popularity lately. And no wonder, because it is an interesting approach to querying data. Therefore, it is definitely worth looking into. At its core, GraphQL is a query language with a runtime that can execute them. Although it is an alternative to REST, it can work alongside it. […]

JavaScript NestJS TypeScript

API with NestJS #26. Real-time chat with WebSockets

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

With WebSockets, we can perform a two-way communication in real-time between the user and the server. Thanks to that, the browser can send messages to the server and listen to information from the other side. The principles of the WebSocket handshake WebSocket is a protocol that operates in a different way than HTTP. Even though […]

JavaScript NestJS TypeScript

API with NestJS #23. Implementing in-memory cache to increase the performance

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

There are quite a few things we can do when tackling our application’s performance. We sometimes can make our code faster and optimize the database queries. To make our API even more performant, we might want to completely avoid running some of the code. Accessing the data stored in the database is quite often time-consuming. […]