Refactor API response structure to use 'body' instead of 'data' for consistency across all endpoints. Update stub responses and documentation accordingly.

This commit is contained in:
Primakov Alexandr Alexandrovich
2025-11-03 18:13:02 +03:00
parent e777b57991
commit daa44521b9
3 changed files with 23 additions and 21 deletions

View File

@@ -50,18 +50,19 @@ stubs/api/
### Успешный ответ
```json
{
"error": null,
"data": <данные>
"success": true,
"body": <данные>
}
```
### Ошибка
```json
{
"success": false,
"body": null,
"error": {
"message": "Описание ошибки"
},
"data": null
}
}
```

View File

@@ -11,14 +11,15 @@ const loadJSON = (filename) => {
return JSON.parse(data);
};
const respond = (res, data) => {
res.json({ error: null, data });
const respond = (res, body) => {
res.json({ success: true, body });
};
const respondError = (res, message, statusCode = 400) => {
res.status(statusCode).json({
error: { message },
data: null
success: false,
body: null,
error: { message }
});
};