📦 製品サービス
製品サービスは、製品エンティティを包括的なCRUD操作と強力なバッチ処理機能で管理するための完全な REST API を提供します。NodeBlocks の関数型合成アプローチで構築され、MongoDB とシームレスに統合します。
🚀 クイックスタート
import express from 'express';
import { middlewares, services, drivers } from '@nodeblocks/backend-sdk';
const { nodeBlocksErrorMiddleware } = middlewares;
const { productService } = services;
const { getMongoClient, createFileStorageDriver } = drivers;
const client = getMongoClient('mongodb://localhost:27017', 'dev');
// 画像アップロードURLエンドポイントで必須:
// GOOGLE_APPLICATION_CREDENTIALS が GCP サービスアカウント JSON に設定されていることを確認してください。
const fileStorageDriver = createFileStorageDriver(
'your-gcp-project-id',
'your-bucket-name'
);
express()
.use(
productService(
{
products: client.collection('products'),
identities: client.collection('identities'),
},
{
authSecrets: {
authEncSecret: 'your-encryption-secret',
authSignSecret: 'your-signing-secret',
},
identity: {
typeIds: {
admin: '100',
guest: '000',
regular: '001',
},
},
},
{ fileStorageDriver }
)
)
.use(nodeBlocksErrorMiddleware())
.listen(8089, () => console.log('Server running'));
📋 エンドポイント概要
個別製品操作
メソッド | パス | 説明 | 認可 |
---|---|---|---|
POST | /products | 新しい製品を作成 | ベアラートークン必須(管理者のみ) |
GET | /products/:productId | IDで製品を取得 | 不要 |
GET | /products | 製品を一覧/フィルタ | 不要 |
PATCH | /products/:productId | 製品を更新 | ベアラートークン必須(管理者のみ) |
DELETE | /products/:productId | 製品を削除 | ベアラートークン必須(管理者のみ) |
POST | /products/:productId/copy | 既存の製品をコピー | ベアラートークン必須(管理者のみ) |
ファイルアップロード操作
メソッド | パス | 説明 | 認可 |
---|---|---|---|
GET | /products/:productId/image-upload-url | 製品画像アップロード用の署名付きURLを取得 | ベアラートークン必須(管理者のみ) |
バッチ製品操作
メソッド | パス | 説明 | 認可 |
---|---|---|---|
POST | /products/batch | 複数の製品を作成 | ベアラートークン必須(管理者のみ) |
PATCH | /products/batch | 複数の製品を更新 | ベアラートークン必須(管理者のみ) |
DELETE | /products/batch | 複数の製品を削除 | ベアラートークン必須(管理者のみ) |
POST | /products/batch/copy | 複数の製品をコピー | ベアラートークン必須(管理者のみ) |
🗄️ エンティティスキーマ
製品エンティティは、自動生成されるベースフィールドと製品固有のデータで構成されます:
{
"name": "string",
"description": "string",
"createdAt": "string (datetime)",
"id": "string",
"updatedAt": "string (datetime)"
}
フィールド詳細
フィールド | 型 | 自動生成 | 必須 | 説明 |
---|---|---|---|---|
name | string | ❌ | ✅ | 製品名 |
description | string | ❌ | ✅ | 製品説明 |
createdAt | datetime | ✅ | ✅ | 作成日時 |
id | string | ✅ | ✅ | 一意識別子(UUID) |
updatedAt | datetime | ✅ | ✅ | 最終更新日時 |
📝 注意: 自動生成フィールドはサービス側で設定され、作成/更新リクエストに含めないでください。レスポンス内のフィールド順序は実際のAPI出力と一致します。
🔐 認証ヘッダー
保護されたエンドポイントでは、次のヘッダーを含めてください:
Authorization: Bearer <admin_access_token>
x-nb-fingerprint: <device_fingerprint>
⚠️ 重要: 認可時にフィンガープリントを指定した場合、認証済みのすべてのリクエストで
x-nb-fingerprint
ヘッダーが必須です。欠如している場合は 401 Unauthorized が返ります。
🔧 APIエンドポイント
1. 製品作成
提供された情報で新しい製品を作成します。
リクエスト:
- メソッド:
POST
- パス:
/products
- ヘッダー:
Content-Type: application/json
,Authorization: Bearer <access-token>
- 認可: ベアラートークン必須(管理者のみ)
リクエストボディ:
フィールド | 型 | 必須 | 説明 |
---|---|---|---|
name | string | ✅ | 製品名 |
description | string | ✅ | 製品説明 |
レスポンスボディ:
フィールド | 型 | 説明 |
---|---|---|
id | string | 一意の製品識別子 |
name | string | 製品名 |
description | string | 製品説明 |
createdAt | string | 作成日時 |
updatedAt | string | 最終更新日時 |
バリデーション:
- スキーマ検証: 自動強制(name、description必須)
- ルートバリデーション:
- 認証済みリクエスト(ベアラー)必須
- 管理者ロール必須
リクエスト例:
curl -X POST {{host}}/products \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access-token>" \
-d '{
"name": "Premium Widget",
"description": "High-quality widget for enterprise use"
}'
成功レスポンス:
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2",
"name": "Premium Widget",
"description": "High-quality widget for enterprise use",
"createdAt": "2024-05-28T09:41:22.552Z",
"updatedAt": "2024-05-28T09:41:22.552Z"
}
エラーレスポンス:
リクエストボディに必須フィールドがない場合:
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"error": {
"message": "Validation Error",
"data": [
"request body must have required property 'name'",
"request body must have required property 'description'"
]
}
}
データベース挿入操作が失敗した場合:
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"error": {
"message": "Failed to create product"
}
}
2. IDで製品取得
一意のIDで特定の製品を取得します。
リクエスト:
- メソッド:
GET
- パス:
/products/:productId
- 認可: 不要
URL パラメータ:
パラメータ | 型 | 必須 | 説明 |
---|---|---|---|
productId | string | ✅ | 一意の製品識別子 |
レスポンスボディ:
フィールド | 型 | 説明 |
---|---|---|
id | string | 一意の製品識別子 |
name | string | 製品名 |
description | string | 製品説明 |
createdAt | string | 作成日時 |
updatedAt | string | 最終更新日時 |
バリデーション:
- スキーマ検証: パスパラメータ検証(productId必須)
- ルートバリデーション: なし
リクエスト例:
curl {{host}}/products/7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2
成功レスポンス:
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2",
"name": "Premium Widget",
"description": "High-quality widget for enterprise use",
"createdAt": "2024-05-28T09:41:22.552Z",
"updatedAt": "2024-05-28T09:41:22.552Z"
}
エラーレスポンス:
指定IDの製品が存在しない場合:
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"error": {
"message": "Product not found"
}
}
3. 製品一覧
フィルタやページングを指定して製品の一覧を取得します。
リクエスト:
- メソッド:
GET
- パス:
/products
- 認可: 不要
クエリパラメータ:
パラメータ | 型 | 必須 | 説明 |
---|---|---|---|
name | string | ❌ | 製品名でフィルタ |
description | string | ❌ | 製品説明でフィルタ |
page | number | ❌ | ページングのページ番号 |
limit | number | ❌ | 1ページあたりの件数 |
レスポンスボディ:
フィールド | 型 | 説明 |
---|---|---|
id | string | 一意の製品識別子 |
name | string | 製品名 |
description | string | 製品説明 |
createdAt | string | 作成日時 |
updatedAt | string | 最終更新日時 |
バリデーション:
- スキーマ検証: クエリパラメータ検証(オプションのname、description、page、limit)
- ルートバリデーション: なし
リクエスト例:
全件取得:
curl {{host}}/products
製品名でフィルタ:
curl "{{host}}/products?name=Premium%20Widget"
ページング指定:
curl "{{host}}/products?page=1&limit=10"
成功レスポンス:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"name": "Premium Widget",
"description": "Updated high-quality widget for enterprise use",
"createdAt": "2025-06-24T06:39:17.101Z",
"id": "3d0e4b74-398c-43e2-a7b4-c9a180477322",
"updatedAt": "2025-06-24T06:39:17.101Z"
},
{
"name": "Product A",
"description": "Updated batch description",
"createdAt": "2025-06-24T06:39:45.378Z",
"id": "0e0dd6c7-c3d5-49e5-a1d8-20daa34d380a",
"updatedAt": "2025-06-24T06:39:55.720Z"
},
{
"name": "Product B",
"description": "Updated batch description",
"createdAt": "2025-06-24T06:39:45.378Z",
"id": "d5a60fdf-2a22-4fcc-8e40-a68cb89cce72",
"updatedAt": "2025-06-24T06:39:55.720Z"
}
]
4. 製品更新
部分更新で既存の製品を更新します。
リクエスト:
- メソッド:
PATCH
- パス:
/products/:productId
- ヘッダー:
Content-Type: application/json
,Authorization: Bearer <access-token>
- 認可: ベアラートークン必須(管理者のみ)
URL パラメータ:
パラメータ | 型 | 必須 | 説明 |
---|---|---|---|
productId | string | ✅ | 一意の製品識別子 |
リクエストボディ(全フィールド任意):
フィールド | 型 | 必須 | 説明 |
---|---|---|---|
name | string | ❌ | 製品名 |
description | string | ❌ | 製品説明 |
レスポンスボディ:
フィールド | 型 | 説明 |
---|---|---|
id | string | 一意の製品識別子 |
name | string | 更新後の製品名 |
description | string | 更新後の製品説明 |
createdAt | string | 作成日時 |
updatedAt | string | 最終更新日時 |
バリデーション:
- スキーマ検証: 自動強制(部分更新、全フィールド任意、追加プロパティ不許可)
- ルートバリデーション:
- 認証済みリクエスト(ベアラー)必須
- 管理者ロール必須
リクエスト例:
curl -X PATCH {{host}}/products/7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access-token>" \
-d '{"description": "Updated high-quality widget for enterprise use"}'
成功レスポンス:
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2",
"name": "Premium Widget",
"description": "Updated high-quality widget for enterprise use",
"createdAt": "2024-05-28T09:41:22.552Z",
"updatedAt": "2024-05-28T14:22:15.789Z"
}
エラーレスポンス:
指定IDの製品が存在しない場合:
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"error": {
"message": "Product not found"
}
}
5. 製品削除
システムから製品を完全に削除します。
リクエスト:
- メソッド:
DELETE
- パス:
/products/:productId
- ヘッダー:
Authorization: Bearer <access-token>
- 認可: ベアラートークン必須(管理者のみ)
URL パラメータ:
パラメータ | 型 | 必須 | 説明 |
---|---|---|---|
productId | string | ✅ | 一意の製品識別子 |
レスポンスボディ:
フィールド | 型 | 説明 |
---|---|---|
なし | - | 成功時はレスポンスボディなし |
バリデーション:
- スキーマ検証: パスパラメータ検証(productId必須)
- ルートバリデーション:
- 認証済みリクエスト(ベアラー)必須
- 管理者ロール必須
リクエスト例:
curl -X DELETE {{host}}/products/7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2 \
-H "Authorization: Bearer <access-token>"
成功レスポンス:
HTTP/1.1 204 No Content
エラーレスポンス:
指定IDの製品が存在しない場合:
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"error": {
"message": "Product not found"
}
}
6. 製品コピー
既存の製品のコピーを新しいIDで作成します。
リクエスト:
- メソッド:
POST
- パス:
/products/:productId/copy
- ヘッダー:
Authorization: Bearer <access-token>
- 認可: ベアラートークン必須(管理者のみ)
URL パラメータ:
パラメータ | 型 | 必須 | 説明 |
---|---|---|---|
productId | string | ✅ | コピーする製品のID |
レスポンスボディ:
フィールド | 型 | 説明 |
---|---|---|
id | string | コピーされた製品の一意識別子 |
name | string | 製品名(オリジナルからコピー) |
description | string | 製品説明(オリジナルからコピー) |
createdAt | string | 作成日時 |
updatedAt | string | 最終更新日時 |
バリデーション:
- スキーマ検証: パスパラメータ検証(productId必須)
- ルートバリデーション:
- 認証済みリクエスト(ベアラー)必須
- 管理者ロール必須
リクエスト例:
curl -X POST {{host}}/products/7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2/copy \
-H "Authorization: Bearer <access-token>"
成功レスポンス:
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "9abc123f-1cd8-4def-b123-456789abcdef",
"name": "Premium Widget",
"description": "High-quality widget for enterprise use",
"createdAt": "2024-05-28T15:30:45.123Z",
"updatedAt": "2024-05-28T15:30:45.123Z"
}
エラーレスポンス:
指定IDの製品が存在しない場合:
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"error": {
"message": "Product not found"
}
}
🔄 バッチ製品操作
製品サービスは、複数の製品を効率的に管理するための強力なバッチ操作を提供します。
7. 複数製品作成
単一のリクエストで複数の製品を作成します。
リクエスト:
- メソッド:
POST
- パス:
/products/batch
- ヘッダー:
Content-Type: application/json
,Authorization: Bearer <access-token>
- 認可: ベアラートークン必須(管理者のみ)
リクエストボディ:
各々が name
と description
を必要とする製品オブジェクトの配列。
レスポンスボディ:
フィールド | 型 | 説明 |
---|---|---|
id | string | 一意の製品識別子 |
name | string | 製品名 |
description | string | 製品説明 |
createdAt | string | 作成日時 |
updatedAt | string | 最終更新日時 |
バリデーション:
- スキーマ検証: 自動強制(必須のnameおよびdescriptionを含む製品オブジェクトの配列)
- ルートバリデーション:
- 認証済みリクエスト(ベアラー)必須
- 管理者ロール必須
リクエスト例:
curl -X POST {{host}}/products/batch \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access-token>" \
-d '[
{
"name": "Product A",
"description": "Description for Product A"
},
{
"name": "Product B",
"description": "Description for Product B"
}
]'
成功レスポンス:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"name": "Product A",
"description": "Description for Product A",
"createdAt": "2025-06-24T06:39:45.378Z",
"id": "0e0dd6c7-c3d5-49e5-a1d8-20daa34d380a",
"updatedAt": "2025-06-24T06:39:45.378Z"
},
{
"name": "Product B",
"description": "Description for Product B",
"createdAt": "2025-06-24T06:39:45.378Z",
"id": "d5a60fdf-2a22-4fcc-8e40-a68cb89cce72",
"updatedAt": "2025-06-24T06:39:45.378Z"
}
]
8. 複数製品更新
単一のリクエストで複数の製品を同じデータで更新します。
リクエスト:
- メソッド:
PATCH
- パス:
/products/batch
- ヘッダー:
Content-Type: application/json
,Authorization: Bearer <access-token>
- 認可: ベアラートークン必須(管理者のみ)
リクエストボディ:
フィールド | 型 | 必須 | 説明 |
---|---|---|---|
ids | array of strings | ✅ | 更新する製品IDの配列 |
data | object | ✅ | 全製品に適用する更新データ |
data.name | string | ❌ | 新しい製品名 |
data.description | string | ❌ | 新しい製品説明 |
レスポンスボディ:
フィールド | 型 | 説明 |
---|---|---|
id | string | 一意の製品識別子 |
name | string | 更新後の製品名 |
description | string | 更新後の製品説明 |
createdAt | string | 作成日時 |
updatedAt | string | 最終更新日時 |
バリデーション:
- スキーマ検証: 自動強制(ids配列とdataオブジェクト必須)
- ルートバリデーション:
- 認証済みリクエスト(ベアラー)必須
- 管理者ロール必須
リクエスト例:
curl -X PATCH {{host}}/products/batch \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access-token>" \
-d '{
"ids": [
"7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2",
"8fec096b-1bc7-5bfe-c827-3600e8fe2790"
],
"data": {
"description": "Updated batch description"
}
}'
成功レスポンス:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"id": "7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2",
"name": "Product A",
"description": "Updated batch description",
"createdAt": "2024-05-28T09:41:22.552Z",
"updatedAt": "2024-05-28T15:45:12.789Z"
},
{
"id": "8fec096b-1bc7-5bfe-c827-3600e8fe2790",
"name": "Product B",
"description": "Updated batch description",
"createdAt": "2024-05-28T09:41:23.123Z",
"updatedAt": "2024-05-28T15:45:12.789Z"
}
]
9. 複数製品削除
単一のリクエストで複数の製品を削除します。
リクエスト:
- メソッド:
DELETE
- パス:
/products/batch
- ヘッダー:
Content-Type: application/json
,Authorization: Bearer <access-token>
- 認可: ベアラートークン必須(管理者のみ)
リクエストボディ: 削除する製品IDの配列。
レスポンスボディ:
フィールド | 型 | 説明 |
---|---|---|
なし | - | 成功時はレスポンスボディなし |
バリデーション:
- スキーマ検証: 自動強制(文字列の配列)
- ルートバリデーション:
- 認証済みリクエスト(ベアラー)必須
- 管理者ロール必須
リクエスト例:
curl -X DELETE {{host}}/products/batch \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access-token>" \
-d '[
"7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2",
"8fec096b-1bc7-5bfe-c827-3600e8fe2790"
]'
成功レスポンス:
HTTP/1.1 204 No Content
10. 複数製品コピー
単一のリクエストで複数の製品のコピーを作成します。
リクエスト:
- メソッド:
POST
- パス:
/products/batch/copy
- ヘッダー:
Content-Type: application/json
,Authorization: Bearer <access-token>
- 認可: ベアラートークン必須(管理者のみ)
リクエストボディ: コピーする製品IDの配列。
レスポンスボディ:
フィールド | 型 | 説明 |
---|---|---|
id | string | コピーされた製品の一意識別子 |
name | string | 製品名(オリジナルからコピー) |
description | string | 製品説明(オリジナルからコピー) |
createdAt | string | 作成日時 |
updatedAt | string | 最終更新日時 |
バリデーション:
- スキーマ検証: 自動強制(文字列の配列)
- ルートバリデーション:
- 認証済みリクエスト(ベアラー)必須
- 管理者ロール必須
リクエスト例:
curl -X POST {{host}}/products/batch/copy \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access-token>" \
-d '[
"7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2",
"8fec096b-1bc7-5bfe-c827-3600e8fe2790"
]'
成功レスポンス:
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"id": "9abc123f-1cd8-4def-b123-456789abcdef",
"name": "Product A",
"description": "Description for Product A",
"createdAt": "2024-05-28T16:00:00.000Z",
"updatedAt": "2024-05-28T16:00:00.000Z"
},
{
"id": "def456a1-2e3f-4567-8901-23456789bcde",
"name": "Product B",
"description": "Description for Product B",
"createdAt": "2024-05-28T16:00:00.100Z",
"updatedAt": "2024-05-28T16:00:00.100Z"
}
]
11. 製品画像アップロードURL取得
製品画像を安全にアップロードするための署名付きURLを生成します。オブジェクトIDと一時的な署名付きURLを返します。
リクエスト:
- メソッド:
GET
- パス:
/products/:productId/image-upload-url
- ヘッダー:
Authorization: Bearer <token>
- 認可: ベアラートークン必須(管理者のみ)
URL パラメータ:
パラメータ | 型 | 必須 | 説明 |
---|---|---|---|
productId | string | ✅ | 対象製品ID |
クエリパラメータ:
パラメータ | 型 | 必須 | 説明 |
---|---|---|---|
contentType | string | ✅ | 画像MIMEタイプ(例: image/png ) |
contentLength | number | ✅ | ファイルサイズ(バイト単位、最大10MB) |
レスポンスボディ:
フィールド | 型 | 説明 |
---|---|---|
objectId | string | 製品画像用の生成されたストレージオブジェクトID |
url | string | ファイルをアップロードするための署名付きURL |
バリデーション:
- スキーマ検証: 画像アップロードスキーマを使用(コンテンツタイプとサイズ制約)
- ルートバリデーション:
- 認証済みリクエスト(ベアラー)必須
- 管理者ロール必須
リクエスト例:
curl "{{host}}/products/7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2/image-upload-url?contentType=image/webp&contentLength=2097152" \
-H "Authorization: Bearer <access-token>"
成功レスポンス:
{
"objectId": "7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2",
"url": "https://storage.googleapis.com/bucket/products/...&X-Goog-Expires=900&X-Goog-Signature=..."
}
⚙️ 設定オプション
サービス設定
interface ProductServiceConfiguration {
authSecrets: {
authEncSecret: string; // JWT 暗号化シークレット
authSignSecret: string; // JWT 署名シークレット
};
identity?: {
typeIds?: {
admin: string; // 管理者ユーザー種別識別子
guest: string; // ゲストユーザー種別識別子
regular: string; // 一般ユーザー種別識別子
};
};
}
設定詳細
製品サービスの設定は、セキュリティおよびユーザー種別管理の論理グループに整理されています。
🔐 セキュリティ設定
authSecrets
- JWT トークンのセキュリティシークレット
- 型:
{ authEncSecret: string; authSignSecret: string }
- 説明: JWT の暗号化および署名に使用する秘密鍵(トークン検証に使用)
- 必須: 本番環境では必須
- 子プロパティ:
authEncSecret
: JWT ペイロード暗号化の秘密鍵authSignSecret
: JWT 署名検証の秘密鍵
👥 ユーザー種別設定
user.typeIds
- ユーザー種別識別子の設定
- 型:
{ admin?: string; guest?: string; user?: string }
- 説明: ロールベースアクセス制御のためのカスタムユーザー種別識別子
- デフォルト:
undefined
(デフォルトの種別検証を使用) - 子プロパティ:
admin
: 管理者ユーザー種別の識別子- 型:
string
- 説明: 管理者ユーザーのカスタム識別子
- 利用例: 管理操作のロールベースアクセス制御
- 例:
"admin"
,"administrator"
,"superuser"
- 型:
guest
: ゲストユーザー種別の識別子- 型:
string
- 説明: ゲストユーザーのカスタム識別子
- 利用例: 未認証/一時ユーザーの限定的アクセス
- 例:
"guest"
,"visitor"
,"anonymous"
- 型:
user
: 一般ユーザー種別の識別子- 型:
string
- 説明: 一般ユーザーのカスタム識別子
- 利用例: 標準的なユーザー権限
- 例:
"user"
,"member"
,"customer"
- 型:
設定例
const productConfig = {
authSecrets: {
authEncSecret: process.env.AUTH_ENC_SECRET || 'your-enc-secret',
authSignSecret: process.env.AUTH_SIGN_SECRET || 'your-sign-secret'
},
user: {
typeIds: {
admin: '100',
guest: '000',
user: '001'
}
}
};
🚨 エラーハンドリング
製品サービスのエラーは、適切なHTTPステータスコードとJSON形式で返されます:
代表的なエラーコード
ステータス | エラーメッセージ | 説明 |
---|---|---|
400 | Validation Error | リクエストボディ形式が無効または必須フィールドがない |
400 | Failed to create product | データベース挿入操作が挿入されたIDを返せなかった |
400 | Failed to update product | 更新操作でデータが変更されない(変更なし) |
400 | Failed to create products | バッチ作成操作が失敗した |
400 | Failed to update products | バッチ更新操作が失敗した |
400 | Failed to delete products | バッチ削除操作が失敗した |
400 | Failed to copy product | 製品コピー操作が失敗した |
400 | Failed to copy products | バッチコピー操作が失敗した |
401 | token could not be verified | 認可トークンがない/無効 |
403 | User is not authorized to access this resource | 必要な権限がない(管理者アクセス) |
404 | Product not found | 要求された操作の対象製品が存在しない |
500 | Failed to create product | 作成中のDB接続問題/予期せぬ失敗 |
500 | Failed to get product | 取得中のDB接続問題/予期せぬ失敗 |
500 | Failed to find products | 一覧取得中のDB接続問題/フィルタ構文不正/予期せぬ失敗 |
500 | Failed to update product | 更新中のDB接続問題/予期せぬ失敗 |
500 | Failed to delete product | 削除中のDB接続問題/予期せぬ失敗 |
500 | Failed to copy product | コピー中のDB接続問題/予期せぬ失敗 |
エラーレスポンス形式
{
"error": {
"message": "Error message description",
"data": ["Additional error details"]
}
}
検証エラーには追加の詳細が含まれます:
{
"error": {
"message": "Validation Error",
"data": [
"request body must have required property 'name'",
"request body must have required property 'description'"
]
}
}
🔗 関連ドキュメント
- ユーザーサービス - ユーザー管理操作
- 組織サービス - 組織管理操作
- 認証サービス - 認証および認可
- エラーハンドリング - エラーパターンの理解
- スキーマコンポーネント - データ検証の概念
- カスタムサービステュートリアル - 独自サービスの構築