Home > Web Front-end > JS Tutorial > An in-depth analysis of the Nest.js framework in node

An in-depth analysis of the Nest.js framework in node

青灯夜游
Release: 2022-02-06 08:00:36
forward
5268 people have browsed it

This article will introduce you to the Nest.js framework in node, and talk about why you choose Nest, how to create and run projects, and receive requests in different ways. I hope it will be helpful to everyone!

An in-depth analysis of the Nest.js framework in node

Recently I am considering making a todolist platform with my friends for my own use. I learned express a long time ago and want to keep pace with the times. Let’s take a look Let’s take a look at some of the most popular frameworks recently. After several comparisons, I chose nest and recorded it after initial use for future reference.

Post Chinese documents for further studyNest

Introduction to Nest.js framework

  • Nest is a framework for building efficient, reliable Extended Node.js Framework for server-side applications. It uses Progressive JavaScript, has built-in and full support for TypeScript (but still allows developers to write code in pure JavaScript) and combines OOP (Object Oriented Programming), FP (Functional Programming) and FRP (Functional Programming) elements of reactive programming.
  • The underlying HTTP platform of the Nest framework is implemented based on Express by default, so there is no need to worry about the lack of third-party libraries. Nest aims to be a platform-agnostic framework. The platform enables the creation of reusable logical components that developers can leverage across many different types of applications. Nest currently has two HTTP platforms that support out-of-the-box: express and fastify, which can be introduced directly in the project.

Why choose Nest

  • There are many node frameworks on the market for you to choose from.
  • Express.js is the birth of Node.JS. It is a fast and minimalist JS server-side development framework based on Node.js and Chrome V8 engine.
  • Koa.js is a micro Web framework. It is very simple to write a hello world, but web applications are inseparable from sessions, view templates, routing, file uploads, and log management. These are not provided by Koa, so you need to go to the official Middleware to find them. However, 100 people may find 100 combinations.
  • Egg.js is based on Koa.js, which solves the above problems, integrates the best practices of the community into Koa.js, and is also named Egg.js, and starts multiple processes to make development easier. Update and other issues were solved together. This is very developer friendly, it works right out of the box, and it has the best (better) configuration right out of the box. During the development of Egg.js, ECMAScript introduced async await. Compared with the yield syntax, async is more straightforward to write. Later, Koa.js also followed up.
  • Midway is a Node.js framework developed by the Alibaba team based on the progressive concept, combining OOP and functional programming paradigms. With egg as the underlying framework, and many new features such as good TypeScript definition support, Midway is launched. Interested friends can go to the official documentation to learn
  • Nest.js based on Express.js The full-featured framework Nest.js is packaged on Express.js and makes full use of the characteristics of TypeScript; the advantage of Nest.js is that the community is active and the growth is gratifying. As of now, it has ## in GitHub #43.7k Star is a popular enterprise-level framework recently.
  • Based on the comprehensive consideration of supporting underlying support ts and enterprise level and community activity, here I choose to use nest for learning. Students can choose according to their needs.
Create project

  • Make sure Node.js is installed on your computer (>= 10.13.0)

  • The node version I use here is

    v14.16.1 and the version managed by yarn is 1.22.17

Create project