Category: Express

Express JavaScript NestJS

API with NestJS #89. Replacing Express with Fastify

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

By default, NestJS uses Express under the hood. Moreover, since Express is very popular, NestJS can choose from a broad set of compatible third-party solutions. A significant advantage of NestJS is that it is framework-independent. Instead of using Express, we can use an adapter using another library with a similar request/response pipeline. The most popular […]

Express JavaScript NestJS Testing TypeScript

API with NestJS #9. Testing services and controllers with integration tests

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

In the previous part of this series, we’ve focused on unit tests. This time, we look into integration tests. In this article, we explain their principles and how they differ from unit tests. We write a few of them using Jest to test our services. We also look into the SuperTest library to test our controllers. […]

Express JavaScript NestJS TypeScript

API with NestJS #6. Looking into dependency injection and modules

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

NestJS strives to focus on the maintainability and testability of the code. To do so, it implements various mechanisms such as the Dependency Injection. In this article, we inspect how NestJS can resolve dependencies by looking into the output of the TypeScript compiler. We also strive to understand the modular architecture that NestJS is built […]

Express JavaScript TypeScript

TypeScript Express tutorial #14. Code optimization with Mongoose Lean Queries

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

Mongoose does quite a bit of heavy-lifting for us. It is immensely useful, but not necessary in every case. In this article, we explore the Mongoose documents more and learn what we can achieve by giving up their benefits. Mongoose Document In the second part of this series, we’ve created our first models. They allow […]

Express JavaScript TypeScript

TypeScript Express tutorial #13. Using Mongoose virtuals to populate documents

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

Throughout this series, we’ve created some schemas and models for documents. We’ve also established ways to define relationships between them. We sometimes find ourselves needing many different properties in our documents. They sometimes overlap each other, and we might want to avoid duplicating the data in the database. Also, we might want to avoid two-way […]

Express JavaScript

JavaScript design patterns #4. Decorators and their implementation in TypeScript

This entry is part 4 of 5 in the JavaScript design patterns

When we are cold, we put on a shirt. If that’s not enough, we put a coat on top. Decorators work similarly. In this article, we discuss the principles of the decorator design pattern and talk about their implementation in TypeScript. We also briefly mention the JavaScript implementation of decorators using Babel. The basics of […]

Express JavaScript Node.js

TypeScript Express tutorial #12. Creating a CI/CD pipeline with Travis and Heroku

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

Once our application is up and running, we want to deploy it. In this article, we explain what Continous Integration (CI) and Continuous Delivery (CD) is. We use Travis and Heroku as an example, but the knowledge can be used with other tools also. Both Travis and Heroku can be tried out for free. Continuous […]

Express JavaScript Node.js

TypeScript Express tutorial #11. Node.js Two-Factor Authentication

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

Identity theft is a serious issue nowadays. With so many accidents happening on the web, it is a great time to learn about providing an additional layer of security for our users. In this article, we go through the principles and implementation of Node.js Two-Factor Authentication (2FA). We do that by using Google Authenticator and […]