Module
- AppModule(root)
- 밀접하게 관련된 기능의 집합으로 구성. 기본적으로 싱글톤
- cli 로 module 생성
Controller
- Client로부터 들어오는 요청을 처리하고 응답을 반환. 라우터 역할
@Controller
를 통해 정의
- Handler :
@Get, @Post, @Delete
등 컨트롤러 클래스 내의 메서드
- cli 로 controller 생성
Provider
- 종속성을 주입할 수 있음
객체의 인스턴스를 연결하는 기능은 Nest 런타임 시스템에 위임될 수 있음
- Service, Repository, Factory, Helper 등
- Nest에 등록해야 사용 가능. module 파일에 등록
Service
@Injectable()
를 이용해서 애플리케이션 전체에서 사용 가능
- 데이터의 유효성 체크, 데이터베이스의 아이템 생성 등 요청의 핵심 로직 처리
- cli 로 service 생성
<aside>
📌 Dependency Injection
Controller 에서 Service 를 사용 가능하게 함
constructor(생성자) 안에서 이루어짐
</aside>
Model
- Class: 변수의 타입 체크, 인스턴스 생성 가능