NestJS
https://gyazo.com/3f0994f5aa64b5d1b4e16fbaee573cc6
NestJS - A progressive Node.js framework
特徴
DI Dependency Injection
依存注入
オブジェクト class クラス同士の依存を外部から設定
オブジェクト同士の依存を内部で解決しないことで、Testabaleで汎用性の高いコードを書ける
自然と依存関係を意識したコードが書ける
Opinionated Architecture
DI Dependency Injectionを前提としたService サービスとそれを利用する Provider プロバイダー / モジュール modules
汎用的なService サービス
Application向けの入り口のモジュール modules
Progressive Eccosystem
オフィシャルパッケージいっぱい
利点
デフォルトTypeScript
nest-cliで楽、統一性でる
OpenAPIで出力しやすい
Express.jsのMiddleware ミドルウェア使い回せる
実装と疎結合 Loose couplingになるようなArchitecture アーキテクチャ
デコレータによる機能追加が便利!
実装
Controller コントローラorモジュール modules?それ以外は、Service サービスとして実装し、Provider プロバイダーとして提供
Test テスト Testing
Documentation | NestJS - A progressive Node.js framework
使用: Jest
プロバイダー Provider
https://docs.nestjs.com/assets/Components_1.png
モジュール modules
https://docs.nestjs.com/assets/Modules_1.png
困りごと
PostgreSQLとの連携
Nest.jsのDB接続周りでハマった話 - Qiita
参考
NestJS meetup Tokyo Opening Talk / What is NestJS? #nestjs_meetup - Speaker Deck
触って覚える NestJS のアーキテクチャの基本 - Qiita
NestJS a progressive web framework - Speaker Deck
公式以外のTutorial
How to Build Web APIs with NestJS, Postgres, and Sequelize - A Beginner's Guide
API with NestJS #1. Controllers, routing and the module structure
How To Set Up TypeORM With Postgres in NestJS | by DLT Labs | Better Programming | Medium