Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Nest.js: A Progressive Node.js Framework
  • Table Of Contents Toc
Nest.js: A Progressive Node.js Framework

Nest.js: A Progressive Node.js Framework

By : Greg Magolan, Patrick Housley, Adrien de Peretti, Jay Bell, David Guijarro
close
close
Nest.js: A Progressive Node.js Framework

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)
close
close

Nest CLI

New in version 5 of Nest there is a CLI that allows for command line generation of projects and files. The CLI can be installed globally with:

npm install -g @nestjs/cli

Or through Docker with:

docker pull nestjs/cli:[version]

A new Nest project can be generated with the command:

nest new [project-name]

This process will create the project from a typescript-starter and will ask for the name, description, version (defaults to 0.0.0), and author (this would be your name). After this process is finished you will have a fully setup Nest project with the dependencies installed in your node_modules folder. The new command will also ask what package manager you would like to use, in the same way that either yarn or npm can be used. Nest gives you this choice during creation.

The most used command from the CLI will be the generate (g) command, this will allow you to create new controllers, modules, servies or any other components that Nest supports. The list of available components is:

  1. class (cl)
  2. controller (co)
  3. decorator (d)
  4. exception (e)
  5. filter (f)
  6. gateway (ga)
  7. guard (gu)
  8. interceptor (i)
  9. middleware (mi)
  10. module (mo)
  11. pipe (pi)
  12. provider (pr)
  13. service (s)

Note that the string in the brackets is the alias for that specific command. This means that instead of typing:

nest generate service [service-name]

In your console, you can enter:

nest g s [service-name]

Lastly, the Nest CLI provides the info (i) command to display information about your project. This command will output information that looks something like:

[System Information]
OS Version     : macOS High Sierra
NodeJS Version : v8.9.0
YARN Version    : 1.5.1
[Nest Information]
microservices version : 5.0.0
websockets version    : 5.0.0
testing version       : 5.0.0
common version        : 5.0.0
core version          : 5.0.0
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Nest.js: A Progressive Node.js Framework
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon