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)

Summary

TypeORM is a very useful tool and enables us to do a lot of heavy lifting when dealing with databases, while greatly abstracting things like data modelling, queries, and complex joins, thus simplifying our code.

It’s also very suitable for being used in Nest.js-based projects thanks to the great support the framework provides through the @nest/typeorm package.

Some of the things that we covered in this chapter are:

  • The database types supported by TypeORM and some hints on how to choose one.
  • How to connect TypeORM to your database.
  • What is an entity and how to create your first one.
  • Storing and retrieving data from your database.
  • Leveraging TypeORM to make it easier working with metadata (ID’s, creation and modification dates...).
  • Customizing the type of columns in your database to match your needs.
  • Building relationships between your different entities and how to handle them when reading from and writing to the database.
  • More advanced procedures like reusing code...