/nestjsone

simple projetct

Primary LanguageTypeScript

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

The first project covers the basics of using Nest framework, providing explanations of how each component functions and its responsibilities. Subsequent projects will build upon this foundation by adding additional content and concepts related to this framework.

Prerequisites

Node.js (version >= 16) is installed and Package Manager on your operating system. Which package manager would you 🙄 to use? npm

First steps

$ npm i -g @nestjs/cli
$ nest new project-name

Project created

📁src/
  🌟  app.controller.spec.ts -  Unit tests   
  🌟  app.controller.ts - Controller with a single route
  🌟  app.module.ts - The root module
  🌟  app.service.ts - Service with a single method
  ☠️  main.ts - Core function - (express/fastify)

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Notes

Lifecycle Events

#initializing
🐱‍🏍 Bootstrappong starts
# Resolves host module dependencies(Controllers, Providers ..)

🐱‍🏍 onModuleInit 
# Called once the host module's dependencies have been resolved

🐱‍🏍 onApplicationBootstrap
#Called once all modules have been initialized, but before listening for connections.

#running

🎮 Start listeners
# HTTP server, WS server

🎮 Appication is running

#terminating N\a
Controllers

Responsible for handling incoming requests and returning responses to the client.

Providers

The main idea of a provider is that it can be injected as a dependency.

Modules

Nest makes use of to organize the application structure.

Middleware

Function which is called before the route handler.

Filters/Pipes

Guards

Guards have a single responsibility. They determine whether a given request will be handled by the route handler or not,depending on certain conditions

Interceptors

The details Lifecycle

Evolution

  • Branch feature/

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

References

License

Nest is MIT licensed.