🛣️ 属性ルート
属性ルートは、Nodeblocksアプリケーションで属性グループ管理のための事前設定済みHTTPエンドポイントを提供します。これらのルートは、ハンドラー、バリデーター、ロギング、ページネーションを組み合わせて、適切な認証、認可、エラーハンドリングを含む完全なAPIエンドポイントを作成します。
🎯 概要
属性ルートは以下の目的で設計されています:
- 完全なAPIエンドポイントの提供 - 属性グループ管理操作のためのエンドポイント
- ハンドラーとバリデーターの組み合わせ - 安全な操作のための統合
- 認証と認可のチェック - 変更操作エンドポイントでの実装
- 関数型コンポジションパターンのサポート - 関数合成の対応
- ロギングとエラー管理の自動処理 - 自動的なエラーハンドリング
- ページネーションのサポート - 一覧表示での対応
📋 ルート構造
各属性ルートは一貫したパターンに従います:
- HTTPメソッド: 操作タイプを定義(GET、POST、PATCH、DELETE)
- Path: パラメータを含むエンドポイントURLを指定
- ハンドラー: ビジネスロジック用の合成関数チェーン
- バリデーター: 認証と認可のチェック
🔧 利用可能な属性ルート
createAttributeRoute
新しい属性グループを作成し、作成されたリソースを返します。
目的: 属性グループの作成を処理
ルート詳細:
- Method:
POST - Path:
/attributes - 認証: 必須(Bearerトークン、admin)
ハンドラー: ロギングとコンポジションを含む — createAttributeGroup → getAttributeGroupById → createAttributeGroupTerminator
バリデーター: isAuthenticated()、checkIdentityType(['admin'])
使用例:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.createAttributeRoute);
findAttributesRoute
正規化されたリスト形式ですべての属性グループを取得します。
目的: ページネーションを含む属性グループの一覧表示
ルート詳細:
- Method:
GET - Path:
/attributes - 認証: 不要
ハンドラー: ページネーションとロギングを含む — findAttributeGroups → normalizeAttributesListTerminator
バリデーター: なし
クエリパラメータ
name?: string— 名前によるオプションフィルタpage?: number— ページネーション(1–1000)limit?: number— ページネーション(1–50)
使用例:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.findAttributesRoute);
getAttributeRoute
IDで特定の属性グループを取得します。
目的: 属性グループデータの取得
ルート詳細:
- Method:
GET - Path:
/attributes/:attributeId - 認証: 不要
ハンドラー: ロギングを含む — getAttributeGroupById → normalizeAttributeGroupTerminator
バリデーター: なし
使用例:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.getAttributeRoute);
updateAttributeRoute
既存の属性グループを更新し、更新されたリソースを返します。
目的: 属性グループデータの変更
ルート詳細:
- Method:
PATCH - Path:
/attributes/:attributeId - 認証: 必須(Bearerトークン、admin)
ハンドラー: ロギングを含む — updateAttributeGroup → getAttributeGroupById → normalizeAttributeGroupTerminator
バリデーター: isAuthenticated()、checkIdentityType(['admin'])
使用例:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.updateAttributeRoute);
deleteAttributeRoute
IDで属性グループを削除します。
目的: 属性グループの削除
ルート詳細:
- Method:
DELETE - Path:
/attributes/:attributeId - 認証: 必須(Bearerトークン、admin)
ハンドラー: ロギングを含む — deleteAttributeGroup → deleteAttributeTerminator
バリデーター: isAuthenticated()、checkIdentityType(['admin'])
使用例:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.deleteAttributeRoute);