모듈 클래스는 모듈 클래스는 @Module()
데코레이터를 가짐.
Nest 애플리케이션에는 최소 하나의 모듈, 즉 루트 모듈 이 있으며, 이 모듈은 Nest가 애플리케이션 그래프(**application graph)**를 구축하는 시작점 역할을 함
<aside> 💡
Nest가 모듈과 제공자 간의 관계와 종속성을 확인하는 데 사용하는 내부 구조
</aside>
@Module()
Nest가 어플리케이션 구조를 효율적으로 관리할 수 있도록 메타데이터를 제공하는 역할
다음의 속성들을 가지는 하나의 객체를 받음
속성 | 설명 |
---|---|
providers |
the providers that will be instantiated by the Nest injector and that may be shared at least across this module |
controllers |
the set of controllers defined in this module which have to be instantiated |
imports |
the list of imported modules that export the providers which are required in this module |
exports |
the subset of providers that are provided by this module and should be available in other modules which import this module. You can use either the provider itself or just its token (provide value) |
import { Module } from '@nestjs/common';
import { CatsController } from './cats.controller';
import { CatsService } from './cats.service';
@Module({
controllers: [CatsController],
providers: [CatsService],
})
export class CatsModule {}