Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте What Are Modules in Nest.js | Section
Building Backend Applications with Nest.js

bookWhat Are Modules in Nest.js

Свайпніть щоб показати меню

Modules are used to organize your application into separate parts.

As your project grows, you will have multiple controllers and services. Modules help you group related functionality together and keep your code structured.

Every Nest.js application has at least one module:

app.module.ts

This is the root module. It connects all parts of your application.

A module looks like this:

import { Module } from '@nestjs/common';
import { UsersController } from './users.controller';
import { UsersService } from './users.service';

@Module({
  imports: [],
  controllers: [UsersController],
  providers: [UsersService],
})
export class AppModule {}

Here is what is happening:

  • controllers: registers controllers used in this module;
  • providers: registers services that can be injected;
  • imports: allows you to use other modules.

Modules help you:

  • Group related features together;
  • Keep your code organized;
  • Scale your application more easily.

Instead of putting everything in one place, you split your application into logical parts.

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 14

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Секція 1. Розділ 14
some-alt