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)

Chapter 15. Server-side Rendering with Angular Universal

If you are not familiar with the Angular platform for client-side application development it is worth taking a look into. Nest.js has a unique symbiotic relationship with Angular because they are both written in TypeScript. This allows for some interesting code sharing between your Nest.js server and Angular app, because Angular and Nest.js both use TypeScript, and classes can be created in a package that is shared between the Angular app and the Nest.js app. These classes can then be included in either app and help keep the objects that are sent and received over HTTP requests between client and server consistent. This relationship is taken to another level when we introduce Angular Universal. Angular Universal is a technology that allows your Angular app to be pre-rendered on your server. This has a number of benefits such as:

  1. Facilitate web crawlers for SEO purposes.
  2. Improve the load performance of your site.
  3. Improve performance...