コンテンツにスキップ

02. CRUD のロジック作成

Dependency injection に対応する

InversifyJS を導入する。

1
npm i inversify reflect-metadata
tsconfig.json
1
2
3
4
5
6
{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

TypeORM と SQLite3 を導入する

1
npm i typeorm reflect-metadata sqlite3

実装する

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
.
├── package-lock.json
├── package.json
├── src
│   ├── app.ts
│   ├── auth
│   ├── container.ts
│   ├── data-source.ts
│   ├── error
│   │   └── todo-not-found-error.ts
│   ├── todo
│   │   ├── i-todo-repository.ts
│   │   ├── i-todo-service.ts
│   │   ├── todo-controller-dto.ts
│   │   ├── todo-controller.ts
│   │   ├── todo-repository-dto.ts
│   │   ├── todo-repository.ts
│   │   ├── todo-service-create-dto.ts
│   │   ├── todo-service-dto.ts
│   │   ├── todo-service-update.dto.ts
│   │   └── todo-service.ts
│   └── types.ts
└── tsconfig.json