ð ã«ããŽãªãµãŒãã¹
Category Serviceã¯ãã¹ããŒã¿ã¹å¶åŸ¡ãåããéå±€ã«ããŽãªã管çããããã®å®å šãªREST APIãæäŸããŸããNodeblocksã®é¢æ°åã³ã³ããžã·ã§ã³ã¢ãããŒããšMongoDBçµ±åã䜿çšããŠãååã«ããŽãªãã³ã³ãã³ãåé¡ãçµç¹æ§é ãåŠçããããã«èšèšãããŠããŸãã
ð ã¯ã€ãã¯ã¹ã¿ãŒãâ
import express from 'express';
import { middlewares, services, drivers } from '@nodeblocks/backend-sdk';
const { nodeBlocksErrorMiddleware } = middlewares;
const { categoryService } = services;
const { withMongo } = drivers;
const connectToDatabase = withMongo('mongodb://localhost:27017', 'dev', 'user', 'password');
express()
.use(
categoryService(
{
...(await connectToDatabase('categories')),
...(await connectToDatabase('identities')),
},
{
authSecrets: {
authEncSecret: 'your-encryption-secret',
authSignSecret: 'your-signing-secret',
},
identity: {
typeIds: {
admin: '100',
guest: '000',
regular: '001',
},
},
}
)
)
.use(nodeBlocksErrorMiddleware())
.listen(8089, () => console.log('Server running'));
ð ãšã³ããã€ã³ãæŠèŠâ
ã«ããŽãªæäœâ
| Method | Path | 説æ | èªèšŒãå¿ èŠ |
|---|---|---|---|
POST | /categories | æ°ããã«ããŽãªãäœæ | â 管çè |
GET | /categories/:categoryId | IDã§ã«ããŽãªãååŸ | â |
GET | /categories | ãã¹ãŠã®ã«ããŽãªããªã¹ã | â |
PATCH | /categories/:categoryId | ã«ããŽãªãæŽæ° | â 管çè |
DELETE | /categories/:categoryId | ã«ããŽãªãåé€ | â 管çè |
ã¹ããŒã¿ã¹ç®¡çæäœâ
| Method | Path | 説æ | èªèšŒãå¿ èŠ |
|---|---|---|---|
POST | /categories/:categoryId/enable | ã«ããŽãªãæå¹åïŒã¹ããŒã¿ã¹ã'active'ã«èšå®ïŒ | â 管çè |
POST | /categories/:categoryId/disable | ã«ããŽãªãç¡å¹åïŒã¹ããŒã¿ã¹ã'inactive'ã«èšå®ïŒ | â 管çè |
ðïž ãšã³ãã£ãã£ã¹ããŒãâ
ã«ããŽãªãšã³ãã£ãã£ã¯ãåºæ¬ãã£ãŒã«ãïŒèªåçæïŒãšã«ããŽãªåºæã®ããŒã¿ãçµã¿åãããŸãïŒ
{
"name": "string",
"description": "string",
"status": "string",
"parent": "string",
"createdAt": "string (datetime)",
"id": "string",
"updatedAt": "string (datetime)"
}
ãã£ãŒã«ã詳现â
| Field | Type | èªåçæ | å¿ é | 説æ |
|---|---|---|---|---|
name | string | â | â | ã«ããŽãªå |
description | string | â | â | ã«ããŽãªã®èª¬æ |
status | string | â | â | ã«ããŽãªã®ã¹ããŒã¿ã¹ïŒ'active'ã'inactive'ãªã©ïŒ |
parent | string | â | â | éå±€æ§é ã®ããã®èŠªã«ããŽãªID |
createdAt | datetime | â | â | äœæã¿ã€ã ã¹ã¿ã³ã |
id | string | â | â | äžæã®èå¥åïŒUUIDïŒ |
updatedAt | datetime | â | â | æçµæŽæ°ã¿ã€ã ã¹ã¿ã³ã |
ð æ³šèš: èªåçæãã£ãŒã«ãã¯ãµãŒãã¹ã«ãã£ãŠèšå®ãããäœæ/æŽæ°ãªã¯ãšã¹ãã«å«ããã¹ãã§ã¯ãããŸããã
parentãã£ãŒã«ãã¯éå±€ã«ããŽãªæ§é ãå¯èœã«ããŸãã
ð èªèšŒããããŒâ
ä¿è·ããããšã³ããã€ã³ãã§ã¯ã次ã®ããããŒãå«ããŠãã ããïŒ
Authorization: Bearer <admin_access_token>
x-nb-fingerprint: <device_fingerprint>
â ïž éèŠ:
x-nb-fingerprintããããŒã¯ãèªèšŒæã«ãã£ã³ã¬ãŒããªã³ããæå®ãããå Žåããã¹ãŠã®èªèšŒæžã¿ãªã¯ãšã¹ãã§å¿ é ã§ããããããªãå Žåããªã¯ãšã¹ãã¯401 Unauthorizedãè¿ããŸãã
ð§ APIãšã³ããã€ã³ãâ
1. ã«ããŽãªã®äœæâ
æäŸãããæ å ±ã§æ°ããã«ããŽãªãäœæããŸãã
ãªã¯ãšã¹ã:
- Method:
POST - Path:
/categories - Headers:
Content-Type: application/jsonAuthorization: Bearer <token>x-nb-fingerprint: <device-fingerprint>
- Authorization: BearerããŒã¯ã³ãå¿ èŠïŒç®¡çè ïŒ
ãªã¯ãšã¹ãããã£:
| Field | Type | å¿ é | 説æ |
|---|---|---|---|
name | string | â | ã«ããŽãªå |
description | string | â | ã«ããŽãªã®èª¬æ |
status | string | â | ã«ããŽãªã®ã¹ããŒã¿ã¹ |
parent | string | â | 芪ã«ããŽãªIDïŒéå±€æ§é çšïŒ |
ã¬ã¹ãã³ã¹ããã£:
| Field | Type | 説æ |
|---|---|---|
name | string | ã«ããŽãªå |
description | string | ã«ããŽãªã®èª¬æ |
status | string | ã«ããŽãªã®ã¹ããŒã¿ã¹ |
parent | string | 芪ã«ããŽãªIDïŒè©²åœããå ŽåïŒ |
createdAt | string | äœæã¿ã€ã ã¹ã¿ã³ã |
id | string | äžæã®ã«ããŽãªèå¥å |
updatedAt | string | æçµæŽæ°ã¿ã€ã ã¹ã¿ã³ã |
ããªããŒã·ã§ã³:
- ã¹ããŒãããªããŒã·ã§ã³: èªåçã«åŒ·å¶ãããŸãïŒnameãdescriptionãstatuså¿ é ïŒ
- ã«ãŒãããªããŒã¿ãŒ:
- èªèšŒæžã¿ãªã¯ãšã¹ããå¿ èŠïŒbearerããŒã¯ã³ïŒ
- 管çè ããŒã«ãå¿ èŠ
ãªã¯ãšã¹ãäŸ:
curl -X POST http://localhost:8089/categories \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <admin_token>" \
-H "x-nb-fingerprint: <device-fingerprint>" \
-d '{
"name": "Electronics",
"description": "Electronic devices and accessories",
"status": "active"
}'
芪ã«ããŽãªä»ããªã¯ãšã¹ãäŸ:
curl -X POST http://localhost:8089/categories \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <admin_token>" \
-H "x-nb-fingerprint: <device-fingerprint>" \
-d '{
"name": "Smartphones",
"description": "Mobile phones and accessories",
"status": "active",
"parent": "682f4a3e-e37e-4480-bc36-dda085e7ce26"
}'
æåã¬ã¹ãã³ã¹:
HTTP/1.1 200 OK
Content-Type: application/json
{
"name": "Electronics",
"description": "Electronic devices and accessories",
"status": "active",
"createdAt": "2025-07-07T07:45:59.013Z",
"id": "682f4a3e-e37e-4480-bc36-dda085e7ce26",
"updatedAt": "2025-07-07T07:45:59.013Z"
}
ãšã©ãŒã¬ã¹ãã³ã¹:
ãªã¯ãšã¹ãããã£ã«å¿ é ãã£ãŒã«ãããªãå Žå:
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"error": {
"message": "Validation Error",
"data": [
"request body must have required property 'description'",
"request body must have required property 'status'"
]
}
}
èªèšŒã倱æããå Žå:
HTTP/1.1 401 Unauthorized
Content-Type: application/json
{
"error": {
"message": "Token fails security check"
}
}
2. IDã§ã«ããŽãªãååŸâ
äžæã®IDã§ç¹å®ã®ã«ããŽãªãååŸããŸãã
ãªã¯ãšã¹ã:
- Method:
GET - Path:
/categories/:categoryId - Authorization: äžèŠ
URLãã©ã¡ãŒã¿:
| Parameter | Type | å¿ é | 説æ |
|---|---|---|---|
categoryId | string | â | äžæã®ã«ããŽãªèå¥å |
ã¬ã¹ãã³ã¹ããã£:
| Field | Type | 説æ |
|---|---|---|
name | string | ã«ããŽãªå |
description | string | ã«ããŽãªã®èª¬æ |
status | string | ã«ããŽãªã®ã¹ããŒã¿ã¹ |
parent | string | 芪ã«ããŽãªIDïŒè©²åœããå ŽåïŒ |
createdAt | string | äœæã¿ã€ã ã¹ã¿ã³ã |
id | string | äžæã®ã«ããŽãªèå¥å |
updatedAt | string | æçµæŽæ°ã¿ã€ã ã¹ã¿ã³ã |
ããªããŒã·ã§ã³:
- ã¹ããŒãããªããŒã·ã§ã³: categoryIdã®ãã¹ãã©ã¡ãŒã¿ããªããŒã·ã§ã³
- ã«ãŒãããªããŒã¿ãŒ:
- ã«ããŽãªãååšããããšãæ€èšŒ
ãªã¯ãšã¹ãäŸ:
curl http://localhost:8089/categories/682f4a3e-e37e-4480-bc36-dda085e7ce26
æåã¬ã¹ãã³ã¹:
HTTP/1.1 200 OK
Content-Type: application/json
{
"name": "Electronics",
"description": "Electronic devices and accessories",
"status": "active",
"createdAt": "2025-07-07T07:45:59.013Z",
"id": "682f4a3e-e37e-4480-bc36-dda085e7ce26",
"updatedAt": "2025-07-07T07:45:59.013Z"
}
ãšã©ãŒã¬ã¹ãã³ã¹:
æå®ãããIDã®ã«ããŽãªãååšããªãå Žå:
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"error": {
"message": "Category does not exist"
}
}
3. ã«ããŽãªã®ãªã¹ãååŸâ
ãã¹ãŠã®ã«ããŽãªã®ãªã¹ããååŸããŸãã
ãªã¯ãšã¹ã:
- Method:
GET - Path:
/categories - Authorization: äžèŠ
ã¯ãšãªãã©ã¡ãŒã¿:
| Parameter | Type | å¿ é | 説æ |
|---|---|---|---|
name | string | â | ã«ããŽãªåã§ãã£ã«ã¿ |
description | string | â | 説æã§ãã£ã«ã¿ |
parent | string | â | 芪ã«ããŽãªIDã§ãã£ã«ã¿ |
status | string | â | ã¹ããŒã¿ã¹ã§ãã£ã«ã¿ |
page | number | â | ããŒãžããŒã·ã§ã³ã®ããŒãžçªå·ïŒ1-1000ïŒ |
limit | number | â | ããŒãžãããã®é ç®æ°ïŒ1-50ïŒ |
ã¬ã¹ãã³ã¹ããã£: ã«ããŽãªé åãšã¡ã¿ããŒã¿ãå«ãããŒãžããŒã·ã§ã³ä»ãã¬ã¹ãã³ã¹ã
ã¬ã¹ãã³ã¹æ§é :
{
"data": [
{
"name": "string",
"description": "string",
"status": "string",
"parent": "string",
"createdAt": "string",
"id": "string",
"updatedAt": "string"
}
],
"metadata": {
"pagination": {
"page": number,
"limit": number,
"total": number,
"totalPages": number,
"hasNext": boolean,
"hasPrev": boolean
}
}
}
ããªããŒã·ã§ã³:
- ã¹ããŒãããªããŒã·ã§ã³: nameãdescriptionãparentãstatusãããŒãžããŒã·ã§ã³ïŒpageãlimitïŒã®ã¯ãšãªãã©ã¡ãŒã¿ããªããŒã·ã§ã³
- ã«ãŒãããªããŒã¿ãŒ: ãªã
ãªã¯ãšã¹ãäŸ:
ãã¹ãŠã®ã«ããŽãªããªã¹ã:
curl http://localhost:8089/categories
ã¹ããŒã¿ã¹ã§ãã£ã«ã¿:
curl "http://localhost:8089/categories?status=active"
æåã¬ã¹ãã³ã¹:
HTTP/1.1 200 OK
Content-Type: application/json
{
"data": [
{
"name": "Electronics",
"description": "Electronic devices and accessories",
"status": "active",
"createdAt": "2025-07-07T07:45:59.013Z",
"id": "682f4a3e-e37e-4480-bc36-dda085e7ce26",
"updatedAt": "2025-07-07T07:45:59.013Z"
},
{
"name": "Smartphones",
"description": "Mobile phones and accessories",
"status": "active",
"parent": "682f4a3e-e37e-4480-bc36-dda085e7ce26",
"createdAt": "2025-07-07T07:46:17.133Z",
"id": "4260c15e-7791-4f09-a846-b6ffa3a73101",
"updatedAt": "2025-07-07T07:46:17.133Z"
}
],
"metadata": {
"pagination": {
"page": 1,
"limit": 10,
"total": 2,
"totalPages": 1,
"hasNext": false,
"hasPrev": false
}
}
}
ããŒãžããŒã·ã§ã³ä»ããªã¯ãšã¹ãäŸ:
curl "http://localhost:8089/categories?page=1&limit=10"
4. ã«ããŽãªã®æŽæ°â
éšåçãªããŒã¿ã§æ¢åã®ã«ããŽãªãæŽæ°ããŸãã
ãªã¯ãšã¹ã:
- Method:
PATCH - Path:
/categories/:categoryId - Headers:
Content-Type: application/json - Authorization: å¿ èŠïŒç®¡çè ïŒ
URLãã©ã¡ãŒã¿:
| Parameter | Type | å¿ é | 説æ |
|---|---|---|---|
categoryId | string | â | äžæã®ã«ããŽãªèå¥å |
ãªã¯ãšã¹ãããã£ïŒãã¹ãŠã®ãã£ãŒã«ãã¯ãªãã·ã§ã³ïŒ:
| Field | Type | å¿ é | 説æ |
|---|---|---|---|
name | string | â | ã«ããŽãªå |
description | string | â | ã«ããŽãªã®èª¬æ |
parent | string | â | 芪ã«ããŽãªID |
â ïž éèŠ:
statusãã£ãŒã«ãã¯æŽæ°ãªã¯ãšã¹ãã§ã¯èš±å¯ãããŸãããã¹ããŒã¿ã¹ã®å€æŽã«ã¯å°çšã®enable/disableãšã³ããã€ã³ãã䜿çšããŠãã ããã
ã¬ã¹ãã³ã¹ããã£:
| Field | Type | 説æ |
|---|---|---|
name | string | æŽæ°ãããã«ããŽãªå |
description | string | æŽæ°ãããã«ããŽãªã®èª¬æ |
status | string | ã«ããŽãªã®ã¹ããŒã¿ã¹ïŒå€æŽãªãïŒ |
parent | string | æŽæ°ããã芪ã«ããŽãªIDïŒè©²åœããå ŽåïŒ |
createdAt | string | äœæã¿ã€ã ã¹ã¿ã³ã |
id | string | äžæã®ã«ããŽãªèå¥å |
updatedAt | string | æçµæŽæ°ã¿ã€ã ã¹ã¿ã³ã |
ããªããŒã·ã§ã³:
- ã¹ããŒãããªããŒã·ã§ã³: èªåçã«åŒ·å¶ãããŸãïŒéšåæŽæ°ãéããããã£ãŒã«ãã®ã¿èš±å¯ïŒ
- ã«ãŒãããªããŒã¿ãŒ:
- èªèšŒæžã¿ãªã¯ãšã¹ããå¿ èŠïŒbearerããŒã¯ã³ïŒ
- 管çè ããŒã«ãå¿ èŠ
- ã«ããŽãªãååšããããšãæ€èšŒ
ãªã¯ãšã¹ãäŸ:
curl -X PATCH http://localhost:8089/categories/682f4a3e-e37e-4480-bc36-dda085e7ce26 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <admin_token>" \
-d '{"description": "Updated electronic devices and accessories"}'
æåã¬ã¹ãã³ã¹:
HTTP/1.1 200 OK
Content-Type: application/json
{
"name": "Electronics",
"description": "Updated electronic devices and accessories",
"status": "active",
"createdAt": "2025-07-07T07:45:59.013Z",
"id": "682f4a3e-e37e-4480-bc36-dda085e7ce26",
"updatedAt": "2025-07-07T07:46:50.017Z"
}
ãšã©ãŒã¬ã¹ãã³ã¹:
æå®ãããIDã®ã«ããŽãªãååšããªãå Žå:
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"error": {
"message": "Category does not exist"
}
}
ãªã¯ãšã¹ãããã£ã«èš±å¯ãããŠããªããã£ãŒã«ããå«ãŸããŠããå Žå:
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"error": {
"message": "Validation Error",
"data": [
"request body must NOT have additional properties"
]
}
}
5. ã«ããŽãªã®åé€â
ã·ã¹ãã ããã«ããŽãªãæ°žç¶çã«åé€ããŸãã
ãªã¯ãšã¹ã:
- Method:
DELETE - Path:
/categories/:categoryId - Authorization: å¿ èŠïŒç®¡çè ïŒ
URLãã©ã¡ãŒã¿:
| Parameter | Type | å¿ é | 説æ |
|---|---|---|---|
categoryId | string | â | äžæã®ã«ããŽãªèå¥å |
ã¬ã¹ãã³ã¹ããã£:
| Field | Type | 説æ |
|---|---|---|
| ã¬ã¹ãã³ã¹ããã£ãªã | - | åé€ãšã³ããã€ã³ãã¯æåæã«ã¬ã¹ãã³ã¹ããã£ãè¿ããŸãã |
ããªããŒã·ã§ã³:
- ã¹ããŒãããªããŒã·ã§ã³: categoryIdã®ãã¹ãã©ã¡ãŒã¿ããªããŒã·ã§ã³
- ã«ãŒãããªããŒã¿ãŒ:
- èªèšŒæžã¿ãªã¯ãšã¹ããå¿ èŠïŒbearerããŒã¯ã³ïŒ
- 管çè ããŒã«ãå¿ èŠ
- ã«ããŽãªãååšããããšãæ€èšŒ
ãªã¯ãšã¹ãäŸ:
curl -X DELETE http://localhost:8089/categories/682f4a3e-e37e-4480-bc36-dda085e7ce26 \
-H "Authorization: Bearer <admin_token>"
æåã¬ã¹ãã³ã¹:
HTTP/1.1 204 No Content
ãšã©ãŒã¬ã¹ãã³ã¹:
æå®ãããIDã®ã«ããŽãªãååšããªãå Žå:
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"error": {
"message": "Category does not exist"
}
}
ð ã¹ããŒã¿ã¹ç®¡çæäœâ
Category Serviceã¯ãã«ããŽãªã®ã¹ããŒã¿ã¹ã管çããããã®å°çšãšã³ããã€ã³ããæäŸããŸãã
6. ã«ããŽãªã®æå¹åâ
ã«ããŽãªã®ã¹ããŒã¿ã¹ã'active'ã«èšå®ããŸãã
ãªã¯ãšã¹ã:
- Method:
POST - Path:
/categories/:categoryId/enable - Authorization: å¿ èŠïŒç®¡çè ïŒ
URLãã©ã¡ãŒã¿:
| Parameter | Type | å¿ é | 説æ |
|---|---|---|---|
categoryId | string | â | äžæã®ã«ããŽãªèå¥å |
ã¬ã¹ãã³ã¹ããã£:
| Field | Type | 説æ |
|---|---|---|
| ã¬ã¹ãã³ã¹ããã£ãªã | - | æå¹åãšã³ããã€ã³ãã¯æåæã«ã¬ã¹ãã³ã¹ããã£ãè¿ããŸãã |
ããªããŒã·ã§ã³:
- ã¹ããŒãããªããŒã·ã§ã³: categoryIdã®ãã¹ãã©ã¡ãŒã¿ããªããŒã·ã§ã³
- ã«ãŒãããªããŒã¿ãŒ:
- èªèšŒæžã¿ãªã¯ãšã¹ããå¿ èŠïŒbearerããŒã¯ã³ïŒ
- 管çè ããŒã«ãå¿ èŠ
- ã«ããŽãªãååšããããšãæ€èšŒ
ãªã¯ãšã¹ãäŸ:
curl -X POST http://localhost:8089/categories/682f4a3e-e37e-4480-bc36-dda085e7ce26/enable \
-H "Authorization: Bearer <admin_token>"
æåã¬ã¹ãã³ã¹:
HTTP/1.1 204 No Content
7. ã«ããŽãªã®ç¡å¹åâ
ã«ããŽãªã®ã¹ããŒã¿ã¹ã'inactive'ã«èšå®ããŸãã
ãªã¯ãšã¹ã:
- Method:
POST - Path:
/categories/:categoryId/disable - Authorization: å¿ èŠïŒç®¡çè ïŒ
URLãã©ã¡ãŒã¿:
| Parameter | Type | å¿ é | 説æ |
|---|---|---|---|
categoryId | string | â | äžæã®ã«ããŽãªèå¥å |
ã¬ã¹ãã³ã¹ããã£:
| Field | Type | 説æ |
|---|---|---|
| ã¬ã¹ãã³ã¹ããã£ãªã | - | ç¡å¹åãšã³ããã€ã³ãã¯æåæã«ã¬ã¹ãã³ã¹ããã£ãè¿ããŸãã |
ããªããŒã·ã§ã³:
- ã¹ããŒãããªããŒã·ã§ã³: categoryIdã®ãã¹ãã©ã¡ãŒã¿ããªããŒã·ã§ã³
- ã«ãŒãããªããŒã¿ãŒ:
- èªèšŒæžã¿ãªã¯ãšã¹ããå¿ èŠïŒbearerããŒã¯ã³ïŒ
- 管çè ããŒã«ãå¿ èŠ
- ã«ããŽãªãååšããããšãæ€èšŒ
ãªã¯ãšã¹ãäŸ:
curl -X POST http://localhost:8089/categories/682f4a3e-e37e-4480-bc36-dda085e7ce26/disable \
-H "Authorization: Bearer <admin_token>"
æåã¬ã¹ãã³ã¹:
HTTP/1.1 204 No Content
ðš ãšã©ãŒãã³ããªã³ã°â
ãã¹ãŠã®ã«ããŽãªãµãŒãã¹ãšã©ãŒã¯ãé©åãªHTTPã¹ããŒã¿ã¹ã³ãŒããšå ±ã«JSON圢åŒã§è¿ãããŸãïŒ
äžè¬çãªãšã©ãŒã³ãŒãâ
| Status | Error Message | 説æ |
|---|---|---|
| 400 | Validation Error | ç¡å¹ãªãªã¯ãšã¹ãããã£åœ¢åŒãŸãã¯å¿ é ãã£ãŒã«ãã®æ¬ èœ |
| 400 | request body must have required property 'name' | ãªã¯ãšã¹ãããã£ã«nameãã£ãŒã«ãããªã |
| 400 | request body must have required property 'description' | ãªã¯ãšã¹ãããã£ã«descriptionãã£ãŒã«ãããªã |
| 400 | request body must have required property 'status' | ãªã¯ãšã¹ãããã£ã«statusãã£ãŒã«ãããªã |
| 400 | request body must NOT have additional properties | ãªã¯ãšã¹ãã«ãµããŒããããŠããªããã£ãŒã«ããå«ãŸããŠãã |
| 400 | Failed to create category | ããŒã¿ããŒã¹æ¿å ¥æäœãæ¿å ¥ãããIDãè¿ããªãã£ã |
| 400 | Failed to update category | æŽæ°æäœãããŒã¿ã倿Žããªãã£ãïŒå€æŽãæ€åºãããªãã£ãïŒ |
| 400 | Failed to delete category | ããŒã¿ããŒã¹å逿äœã倱æãã |
| 401 | Authentication failed | èªèšŒããŒã¯ã³ãæ¬ èœããŠãããç¡å¹ |
| 401 | token could not be verified | èªèšŒããŒã¯ã³ãæ¬ èœããŠãããç¡å¹ |
| 401 | Token fails security check | ããŒã¯ã³ã®ã»ãã¥ãªãã£æ€èšŒã倱æããŸãã |
| 403 | User is not authorized to access this resource | ãŠãŒã¶ãŒã«å¿ èŠãªæš©éããããŸããïŒç®¡çè ã¢ã¯ã»ã¹ïŒ |
| 404 | Category does not exist | ãªã¯ãšã¹ããããæäœã«å¯ŸããŠã«ããŽãªãååšããŸãã |
| 500 | Failed to create category | äœæäžã®ããŒã¿ããŒã¹æ¥ç¶ã®åé¡ãŸãã¯äºæããªã倱æ |
| 500 | Failed to get category | ååŸäžã®ããŒã¿ããŒã¹æ¥ç¶ã®åé¡ãŸãã¯äºæããªã倱æ |
| 500 | Failed to find categories | ãªã¹ãååŸäžã®ããŒã¿ããŒã¹æ¥ç¶ã®åé¡ãç¡å¹ãªãã£ã«ã¿æ§æããŸãã¯äºæããªã倱æ |
| 500 | Failed to update category | æŽæ°äžã®ããŒã¿ããŒã¹æ¥ç¶ã®åé¡ãŸãã¯äºæããªã倱æ |
| 500 | Failed to delete category | åé€äžã®ããŒã¿ããŒã¹æ¥ç¶ã®åé¡ãŸãã¯äºæããªã倱æ |
ãšã©ãŒã¬ã¹ãã³ã¹åœ¢åŒâ
{
"error": {
"message": "ãšã©ãŒã¡ãã»ãŒãžã®èª¬æ",
"data": ["远å ã®ãšã©ãŒè©³çް"]
}
}
ããªããŒã·ã§ã³ãšã©ãŒã«ã¯è¿œå ã®è©³çްãå«ãŸããŸãïŒ
{
"error": {
"message": "Validation Error",
"data": [
"request body must have required property 'description'",
"request body must have required property 'status'"
]
}
}
ð é¢é£ããã¥ã¡ã³ãâ
- Product Service - åå管çæäœ
- Attribute Service - 屿§ç®¡çæäœ
- User Service - ãŠãŒã¶ãŒç®¡çæäœ
- Organization Service - çµç¹ç®¡çæäœ
- Authentication Service - èªèšŒãšèªå¯
- Error Handling - ãšã©ãŒãã¿ãŒã³ã®çè§£
- Schema Component - ããŒã¿ããªããŒã·ã§ã³ã®æŠå¿µ
- Custom Service Tutorial - ç¬èªã®ãµãŒãã¹ãæ§ç¯