Book Image

Nest.js: A Progressive Node.js Framework

By : Greg Magolan, Patrick Housley, Adrien de Peretti, Jay Bell, David Guijarro
Book Image

Nest.js: A Progressive Node.js Framework

By: Greg Magolan, Patrick Housley, Adrien de Peretti, Jay Bell, David Guijarro

Overview of this book

Nest.js is a modern web framework built on a Node.js Express server. With the knowledge of how to use this framework, you can give your applications an organized codebase and a well-defined structure. The book begins by showing how to use Nest.js controllers, providers, modules, bootstrapping, and middleware in your applications. You’ll learn to use the authentication feature of Node.js to manage the restriction access in your application, and how to leverage the Dependency Injection pattern to speed up your application development. As you advance through the book, you'll also see how Nest.js uses TypeORM—an Object Relational Mapping (ORM) that works with several relational databases. You’ll use Nest.js microservices to extract part of your application’s business logic and execute it within a separate Nest.js context. Toward the end of the book, you’ll learn to write tests (both unit tests as well as end-to-end ones) and how to check the percentage of the code your tests cover. By the end of this book, you’ll have all the knowledge you need to build your own Nest.js applications.
Table of Contents (16 chapters)

Configuration

The configuration parameters passed to connectMicroservice depends on the transport we use. A transport is a combination of a client and server that work in unison to transmit microservice requests and responses between the NestApplication and NestMicroservice contexts. Nest.js comes with a number of built-in transports and provides the ability to create custom transports. The available parameters depend on the transport we use. For now, we will use the TCP transport, but will cover other transports later. The possible options for the TCP transport are:

  • host: The host that is running the NestMicroservice context. The default is to assume localhost but this can be used if the NestMicroservice is running as a separate project on a different host such as a different Kubernetes pod.
  • port: The port that the NestMicroservice context is listening on. The default is to assume 3000, but we will use a different port to run our NestMicroservice context.
  • retryAttempts: In the context...