node.js 프로젝트 구조

토이 프로젝트를 진행하기 전, 다른 프로젝트들의 디렉토리 구조를 먼저 파악해보기로 했다.
src app.js - api # Express route controllers for all the endpoints - config # Environment vaiables and configuration related stuff - jobs # Jobs definitions for agenda.js - loaders # Split the startup process into modules - models # Database models - services # All the business logic is here - subscribers # Event handlers for async task - types # Type declaretion files (d.ts) for Typescript
JavaScript
복사
request와 response에 관한 접근은 controller에서만 가능
비지니스 로직은 오직 service에만 정의
어떠한 작업이 side effect가 있을 때 Pub/sub 방식을 이용 → event 사용
의존성 주입 또는 제어 역전을 이용해 코드를 구조화 DI, IoC