티스토리 뷰

728x90

급한대로 일단 Repository를 사용하지 않고 Service단에 Repository 모듈을 사용하려 한다.
현재 Service에 Repository 모듈을 사용하고 module에 TypeOrmModule.forFeature([Entity])를 했음에도 불구하고
User 폴더 밑에 S

ERROR [ExceptionHandler] Nest can't resolve dependencies of the BoardRepository (?). Please make sure that the argument DataSource at index [0] is available in the TypeOrmModule context.

에러가 발생한다.

일단 원인은 찾았다.
아래와 같은 구성에서 user.service에 Repository를 user.module에 TypeOrmModule을 삽입했는데
app.moduole에 TypeOrm을 만들지 않아 생긴 에러이다.
혹시나에서 app.module에 TypeOrm에 DB를 연결 했더니 에러가 사라졌다.

.
├── app.module.ts
├── common
│   ├── apm
│   ├── auth
│   ├── common.module.ts
│   ├── constants
│   ├── databases
│   │   ├── mysql
│   │   │   └── mysql.module.ts
│   │   └── redis
│   │       └── redis.module.ts
│   ├── decorators
│   │   └── typeorm-ex.decorator.ts
│   ├── helper
│   ├── interceptor
│   ├── logger
│   ├── requests
│   └── response
├── configs
│   ├── index.ts
│   ├── mysql.config.ts
│   └── redis.config.ts
├── main.ts
├── modules
│   └── v1
│       ├── boards
│       │   ├── boards.controller.ts
│       │   ├── boards.module.ts
│       │   ├── boards.service.ts
│       │   ├── dto
│       │   │   └── create-board.dto.ts
│       │   └── entities
│       │       └── board.entities.ts
│       └── users
│           ├── cache
│           ├── dtos
│           └── entities
└── router
    └── routes

 

아직 이유는 알지 못한다.
혹시 repository를 생성하지 않아서 발생한 문제일까..