😶 @Modules
providers : Nest 인젝터에 의해 인스턴스화되고 적어도 이 모듈 전체에서 공유될 수 있는 공급자
controllers: 인스턴스화되어야 하는 이 모듈에 정의된 컨트롤러
imports : 이 모듈에 필요한 공급자를 내보내는 가져온 모듈 목록
exports: 하위 집합은 providers 이 모듈에서 제공되며 이 모듈을 가져오는 다른 모듈에서 사용할 수 있어야 한다.
import { Module, Global } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { CatsModule } from './cats/cats.module';
// @Global() : 모듈을 전역 범위로 만듬.
// . 전역 모듈은 일반적으로 루트 또는 코어 모듈에 의해 한 번만 등록되어야 함.
@Global()
@Module({
imports: [CatsModule],
controllers: [AppController],
providers: [AppService],
exports: [CatsModule] //export 사용 시, app.module.ts 모듈을 가져올 경우, CatsModule을 사용 가능.
})
export class AppModule {}
Dynamic-module Sample Code
https://github.com/nestjs/nest/tree/master/sample/25-dynamic-modules
😶 참고
https://www.wisewiredbooks.com/nestjs/overview/05-modules.html
모듈 - 쉽게 풀어 쓴 Nest.js
모듈은 @Module() 데코레이터가 달린 클래스 입니다. @Module() 데코레이터는 Nest가 애플리케이션 구조를 만들때 사용할 수 있는 메타데이터를 제공해주는 역할을 하지요. 각 응용 프로그램에는 적어
www.wisewiredbooks.com
https://docs.nestjs.com/modules
Documentation | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Rea
docs.nestjs.com
'NestJS' 카테고리의 다른 글
[NestJS] Pipes (0) | 2023.09.06 |
---|---|
[NestJS] exception-filters (0) | 2023.09.05 |
[NestJS] Middleware (0) | 2023.09.05 |
[NestJS] Provider, IOC, DI (0) | 2023.09.05 |
[NestJS] SOLID (0) | 2023.09.04 |