nestjs について
NestJS アプリケーションの開発やリファクタリングを行う開発者向けのリファレンススキルです。公式ドキュメントのトピックに沿った例と、一般的な構成要素のテンプレートを収録しています。
主な機能
- 01公式ドキュメントの項目別サンプル
- 02コントローラー、プロバイダー、モジュールの解説
- 03GraphQL、WebSocket、マイクロサービス
- 04セキュリティ、バリデーション、OpenAPI
- 05一般的なコンポーネントのテンプレート
- 06ユニットテストと E2E テスト
活用シーン
- 01NestJS のコントローラーやモジュールを実装
- 02アプリにバリデーションと認可を追加
- 03GraphQL やマイクロサービス機能を設定
- 04ユニットテストや E2E テストを作成
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ partme-ai/ full-stack-skills --skill nestjsインストール後、Claude Code で/nestjsを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
LICENSE.txtapi/decorators.mdexamples/faq.mdexamples/cli/overview.mdexamples/fundamentals/async-providers.mdcircular-dependency.mdcontrollers.mdcustom-decorators.mdcustom-providers.mddynamic-modules.mdexception-filters.mdexecution-context.mdfirst-steps.mdguards.mdinjection-scopes.mdinterceptors.mdlifecycle-events.mdmiddleware.mdmodule-ref.mdmodules.mdpipes.mdproviders.mdrequest-scoped.mdexamples/graphql/directives.mdfederation.mdinterfaces.mdmigration.mdplugins.mdquick-start.mdresolvers.md詳細
このスキルを使うタイミング
次のような要望がある場合は、いつでもこのスキルを使ってください。
- NestJS アプリケーションの構築またはリファクタリング
- コントローラー、プロバイダー、モジュールの実装
- ミドルウェア、パイプ、ガード、インターセプターの適用
- DI スコープ、動的モジュール、ライフサイクルフックの設定
- バリデーション、シリアライゼーション、キャッシュ、ロギング、キューの追加
- GraphQL、WebSockets、マイクロサービスとの連携
- OpenAPI/Swagger による API ドキュメントの作成
- 認証/認可またはセキュリティ強化の実装
- NestJS のユニットテストまたは e2e テストの作成
このスキルの使い方
-
ユーザーのリクエストからトピックを特定し、以下のマッピングで対応するサンプルファイルを探します
-
examples/ディレクトリから適切なサンプルファイルを読み込みます -
構文、構成、ベストプラクティスについて、そのサンプルファイルに記載された具体的な指示に従います
重要な注意事項:
- すべてのサンプルは NestJS 公式ドキュメントの構成に準拠しています
- 該当する場合、サンプルには JavaScript と TypeScript の両方のバージョンが含まれています
- 各サンプルファイルには、主要な概念、コード例、公式ドキュメントへのリンクが含まれています
- ベストプラクティスや一般的なパターンについては、必ずサンプルファイルを確認してください
-
一般的なひな形の作成を効率化するため、
templates/ディレクトリのテンプレートを使います
ドキュメントの対応関係(https://docs.nestjs.com/ と一対一対応)
概要
examples/overview/introduction.md→ https://docs.nestjs.com/examples/fundamentals/first-steps.md→ https://docs.nestjs.com/first-stepsexamples/fundamentals/controllers.md→ https://docs.nestjs.com/controllersexamples/fundamentals/providers.md→ https://docs.nestjs.com/providersexamples/fundamentals/modules.md→ https://docs.nestjs.com/modulesexamples/fundamentals/middleware.md→ https://docs.nestjs.com/middlewareexamples/fundamentals/exception-filters.md→ https://docs.nestjs.com/exception-filtersexamples/fundamentals/pipes.md→ https://docs.nestjs.com/pipesexamples/fundamentals/guards.md→ https://docs.nestjs.com/guardsexamples/fundamentals/interceptors.md→ https://docs.nestjs.com/interceptorsexamples/overview/custom-decorators.md→ https://docs.nestjs.com/custom-decorators
基礎
examples/fundamentals/custom-providers.md→ https://docs.nestjs.com/fundamentals/custom-providersexamples/fundamentals/async-providers.md→ https://docs.nestjs.com/fundamentals/async-providersexamples/fundamentals/dynamic-modules.md→ https://docs.nestjs.com/fundamentals/dynamic-modulesexamples/fundamentals/module-ref.md→ https://docs.nestjs.com/fundamentals/module-refexamples/fundamentals/execution-context.md→ https://docs.nestjs.com/fundamentals/execution-contextexamples/fundamentals/lifecycle-events.md→ https://docs.nestjs.com/fundamentals/lifecycle-eventsexamples/fundamentals/injection-scopes.md→ https://docs.nestjs.com/fundamentals/injection-scopesexamples/fundamentals/request-scoped.md→ https://docs.nestjs.com/fundamentals/request-scopedexamples/fundamentals/circular-dependency.md→ https://docs.nestjs.com/fundamentals/circular-dependency Techniques (技巧)examples/techniques/configuration.md→ https://docs.nestjs.com/techniques/configurationexamples/techniques/validation.md→ https://docs.nestjs.com/techniques/validationexamples/techniques/serialization.md→ https://docs.nestjs.com/techniques/serializationexamples/techniques/caching.md→ https://docs.nestjs.com/techniques/cachingexamples/techniques/logger.md→ https://docs.nestjs.com/techniques/loggerexamples/techniques/events.md→ https://docs.nestjs.com/techniques/eventsexamples/techniques/task-scheduling.md→ https://docs.nestjs.com/techniques/task-schedulingexamples/techniques/queues.md→ https://docs.nestjs.com/techniques/queuesexamples/techniques/file-upload.md→ https://docs.nestjs.com/techniques/file-uploadexamples/techniques/streaming-files.md→ https://docs.nestjs.com/techniques/streaming-filesexamples/techniques/database.md→ https://docs.nestjs.com/techniques/databaseexamples/techniques/mongodb.md→ https://docs.nestjs.com/techniques/mongodbexamples/techniques/mongoose.md→ https://docs.nestjs.com/techniques/mongooseexamples/techniques/sequelize.md→ https://docs.nestjs.com/techniques/sequelizeexamples/techniques/prisma.md→ https://docs.nestjs.com/recipes/prisma
Security (安全)
examples/security/authentication.md→ https://docs.nestjs.com/security/authenticationexamples/security/authorization.md→ https://docs.nestjs.com/security/authorizationexamples/security/helmet.md→ https://docs.nestjs.com/security/helmetexamples/security/cors.md→ https://docs.nestjs.com/security/corsexamples/security/rate-limiting.md→ https://docs.nestjs.com/security/rate-limiting
GraphQL
examples/graphql/quick-start.md→ https://docs.nestjs.com/graphql/quick-startexamples/graphql/resolvers.md→ https://docs.nestjs.com/graphql/resolversexamples/graphql/scalars.md→ https://docs.nestjs.com/graphql/scalarsexamples/graphql/interfaces.md→ https://docs.nestjs.com/graphql/interfacesexamples/graphql/unions.md→ https://docs.nestjs.com/graphql/unionsexamples/graphql/directives.md→ https://docs.nestjs.com/graphql/directivesexamples/graphql/plugins.md→ https://docs.nestjs.com/graphql/pluginsexamples/graphql/subscriptions.md→ https://docs.nestjs.com/graphql/subscriptionsexamples/graphql/federation.md→ https://docs.nestjs.com/graphql/federationexamples/graphql/migration.md→ https://docs.nestjs.com/graphql/migration
WebSockets
examples/websockets/gateways.md→ https://docs.nestjs.com/websockets/gatewaysexamples/websockets/exception-filters.md→ https://docs.nestjs.com/websockets/exception-filtersexamples/websockets/guards.md→ https://docs.nestjs.com/websockets/guardsexamples/websockets/interceptors.md→ https://docs.nestjs.com/websockets/interceptorsexamples/websockets/adapters.md→ https://docs.nestjs.com/websockets/adapters
Microservices
examples/microservices/basics.md→ https://docs.nestjs.com/microservices/basicsexamples/microservices/redis.md→ https://docs.nestjs.com/microservices/redisexamples/microservices/mqtt.md→ https://docs.nestjs.com/microservices/mqttexamples/microservices/nats.md→ https://docs.nestjs.com/microservices/natsexamples/microservices/kafka.md→ https://docs.nestjs.com/microservices/kafkaexamples/microservices/grpc.md→ https://docs.nestjs.com/microservices/grpcexamples/microservices/rabbitmq.md→ https://docs.nestjs.com/microservices/rabbitmqexamples/microservices/custom-transport.md→ https://docs.nestjs.com/microservices/custom-transportexamples/microservices/hybrid-application.md→ https://docs.nestjs.com/microservices/hybrid-application
OpenAPI(Swagger)
examples/openapi/introduction.md→ https://docs.nestjs.com/openapi/introductionexamples/openapi/operations.md→ https://docs.nestjs.com/openapi/operationsexamples/openapi/types-and-parameters.md→ https://docs.nestjs.com/openapi/types-and-parametersexamples/openapi/security.md→ https://docs.nestjs.com/openapi/securityexamples/openapi/mapped-types.md→ https://docs.nestjs.com/openapi/mapped-types
CLI・テスト・レシピ
examples/cli/overview.md→ https://docs.nestjs.com/cli/overviewexamples/testing/unit-testing.md→ https://docs.nestjs.com/fundamentals/testingexamples/testing/e2e-testing.md→ https://docs.nestjs.com/fundamentals/testingexamples/recipes/cqrs.md→ https://docs.nestjs.com/recipes/cqrsexamples/recipes/mikroorm.md→ https://docs.nestjs.com/recipes/mikroormexamples/recipes/terminus.md→ https://docs.nestjs.com/recipes/terminusexamples/faq.md→ https://docs.nestjs.com/faq
例とテンプレート
このスキルには、NestJS の公式ドキュメントの構成(https://docs.nestjs.com/)に合わせて整理された詳細な例が含まれています。すべての例は examples/ ディレクトリにあり、トピックごとに整理されています(上記の対応表を参照)。
例の使用方法:
- ユーザーのリクエストからトピックを特定します
- 上記の対応表から適切な例のファイルを読み込みます
- そのファイルの手順、構文、ベストプラクティスに従います
- コード例を具体的なユースケースに合わせて調整します
テンプレートの使用方法:
- 一般的なスキャフォールディングには、
templates/ディレクトリ内のテンプレートを参照します - テンプレートには、コントローラー、プロバイダー、モジュール、ミドルウェア、ガード、パイプ、インターセプター、例外フィルター、DTO、プロジェクト構成が含まれます
- テンプレートを具体的なニーズやコーディングスタイルに合わせて調整します
ベストプラクティス
- 依存性注入を使用する:NestJS の DI コンテナーを活用し、テスト容易性と保守性を高めます
- モジュールごとに整理する:関連する機能をフィーチャーモジュールにまとめます
- デコレーターを一貫して使用する:コントローラー、プロバイダー、ルートには NestJS のデコレーターパターンに従います
- 入力データを検証する:リクエストの検証には ValidationPipe と DTO を使用します
- エラーを適切に処理する:一貫したエラー処理のために、グローバル例外フィルターを実装します
- 認可にはガードを使用する:インラインチェックではなく、ガードでルートを保護します
- インターセプターを活用する:ロギングや変換など、横断的な関心事にはインターセプターを使用します
- 型安全性:型安全性と開発者エクスペリエンスを高めるために TypeScript を使用します
- 十分にテストする:サービスには単体テストを、API エンドポイントには E2E テストを作成します
- 公式のパターンに従う:推奨されるパターンやプラクティスについては、公式ドキュメントを参照します
リソース
- 公式ドキュメント:https://docs.nestjs.com/
- GitHub リポジトリ:https://github.com/nestjs/nest
キーワード
NestJS、Node.js、フレームワーク、コントローラー、プロバイダー、モジュール、ミドルウェア、例外フィルター、パイプ、ガード、インターセプター、依存性注入、GraphQL、WebSocket、マイクロサービス、OpenAPI、Swagger、テスト、検証、キャッシュ、ロギング、TypeScript、デコレーター、DI、IoC、コントローラー、プロバイダー、モジュール、ミドルウェア、ガード、パイプ、インターセプター、依存性注入