feat(tasks): implement CRUD endpoints with Supabase integration
This commit is contained in:
@@ -135,22 +135,75 @@ Content-Type: application/json
|
||||
|
||||
---
|
||||
|
||||
### 2. Tarefas (Tasks) - Em Desenvolvimento
|
||||
### 2. Tarefas (Tasks)
|
||||
|
||||
#### 2.1 Listar Tarefas
|
||||
#### 2.1 Criar Tarefa
|
||||
```http
|
||||
POST /tasks
|
||||
Authorization: Bearer {token}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"title": "Fazer compras",
|
||||
"description": "Ir ao supermercado",
|
||||
"dueDate": "2025-12-25T00:00:00Z",
|
||||
"category": "compras",
|
||||
"priority": "high",
|
||||
"completed": false
|
||||
}
|
||||
```
|
||||
|
||||
**Response (201 Created):**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Tarefa criada com sucesso",
|
||||
"data": {
|
||||
"id": "6b1f2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
|
||||
"user_id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"title": "Fazer compras",
|
||||
"description": "Ir ao supermercado",
|
||||
"completed": false,
|
||||
"due_date": "2025-12-25T00:00:00Z",
|
||||
"category": "compras",
|
||||
"priority": "high",
|
||||
"created_at": "2025-12-01T10:00:00Z",
|
||||
"updated_at": "2025-12-01T10:00:00Z"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Validações:**
|
||||
- `title`: Obrigatório, mínimo 3 caracteres, máximo 255
|
||||
- `description`: Opcional, máximo 2000 caracteres
|
||||
- `priority`: low | medium (default) | high
|
||||
- `dueDate`, `category`: Opcionais
|
||||
|
||||
**Erros:**
|
||||
- `400 Bad Request` - Validação falhou
|
||||
- `401 Unauthorized` - Token inválido
|
||||
|
||||
---
|
||||
|
||||
#### 2.2 Listar Tarefas
|
||||
```http
|
||||
GET /tasks
|
||||
Authorization: Bearer {token}
|
||||
|
||||
# Query params opcionais:
|
||||
?status=all|completed|pending
|
||||
?sort=created_at|updated_at
|
||||
?completed=true|false
|
||||
?category=compras
|
||||
?priority=low|medium|high
|
||||
?sortBy=created_at|due_date|priority
|
||||
?order=asc|desc
|
||||
```
|
||||
|
||||
**Response (200 OK):**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Tarefas recuperadas com sucesso",
|
||||
"count": 5,
|
||||
"data": [
|
||||
{
|
||||
"id": "6b1f2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
|
||||
@@ -158,18 +211,28 @@ Authorization: Bearer {token}
|
||||
"title": "Fazer compras",
|
||||
"description": "Ir ao supermercado",
|
||||
"completed": false,
|
||||
"due_date": "2025-12-25T00:00:00Z",
|
||||
"category": "compras",
|
||||
"priority": "high",
|
||||
"created_at": "2025-12-01T10:00:00Z",
|
||||
"updated_at": "2025-12-01T10:00:00Z"
|
||||
}
|
||||
],
|
||||
"total": 1,
|
||||
"page": 1
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**Query Exemplos:**
|
||||
- `GET /tasks?completed=false` - Tarefas pendentes
|
||||
- `GET /tasks?priority=high&sortBy=due_date` - Prioridade alta, ordenadas por vencimento
|
||||
- `GET /tasks?category=trabalho&order=asc` - Categoria trabalho, ordem ascendente
|
||||
|
||||
**Erros:**
|
||||
- `400 Bad Request` - Query inválida
|
||||
- `401 Unauthorized` - Token inválido
|
||||
|
||||
---
|
||||
|
||||
#### 2.2 Obter Tarefa Específica
|
||||
#### 2.3 Obter Tarefa Específica
|
||||
```http
|
||||
GET /tasks/:id
|
||||
Authorization: Bearer {token}
|
||||
@@ -178,49 +241,25 @@ Authorization: Bearer {token}
|
||||
**Response (200 OK):**
|
||||
```json
|
||||
{
|
||||
"id": "6b1f2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
|
||||
"user_id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"title": "Fazer compras",
|
||||
"description": "Ir ao supermercado",
|
||||
"completed": false,
|
||||
"created_at": "2025-12-01T10:00:00Z",
|
||||
"updated_at": "2025-12-01T10:00:00Z"
|
||||
"success": true,
|
||||
"message": "Tarefa recuperada com sucesso",
|
||||
"data": {
|
||||
"id": "6b1f2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
|
||||
"user_id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"title": "Fazer compras",
|
||||
"description": "Ir ao supermercado",
|
||||
"completed": false,
|
||||
"due_date": "2025-12-25T00:00:00Z",
|
||||
"category": "compras",
|
||||
"priority": "high",
|
||||
"created_at": "2025-12-01T10:00:00Z",
|
||||
"updated_at": "2025-12-01T10:00:00Z"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Erros:**
|
||||
- `404 Not Found` - Tarefa não encontrada
|
||||
- `401 Unauthorized` - Token inválido
|
||||
|
||||
---
|
||||
|
||||
#### 2.3 Criar Tarefa
|
||||
```http
|
||||
POST /tasks
|
||||
Authorization: Bearer {token}
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"title": "Fazer compras",
|
||||
"description": "Ir ao supermercado"
|
||||
}
|
||||
```
|
||||
|
||||
**Response (201 Created):**
|
||||
```json
|
||||
{
|
||||
"id": "6b1f2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
|
||||
"user_id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"title": "Fazer compras",
|
||||
"description": "Ir ao supermercado",
|
||||
"completed": false,
|
||||
"created_at": "2025-12-01T10:00:00Z",
|
||||
"updated_at": "2025-12-01T10:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
**Erros:**
|
||||
- `400 Bad Request` - Título obrigatório
|
||||
- `404 Not Found` - Tarefa não encontrada ou não pertence ao usuário
|
||||
- `401 Unauthorized` - Token inválido
|
||||
|
||||
---
|
||||
@@ -234,23 +273,35 @@ Content-Type: application/json
|
||||
{
|
||||
"title": "Fazer compras (atualizado)",
|
||||
"description": "Ir ao supermercado e padaria",
|
||||
"completed": true
|
||||
"completed": true,
|
||||
"dueDate": "2025-12-20T00:00:00Z",
|
||||
"priority": "medium"
|
||||
}
|
||||
```
|
||||
|
||||
**Response (200 OK):**
|
||||
```json
|
||||
{
|
||||
"id": "6b1f2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
|
||||
"user_id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"title": "Fazer compras (atualizado)",
|
||||
"description": "Ir ao supermercado e padaria",
|
||||
"completed": true,
|
||||
"created_at": "2025-12-01T10:00:00Z",
|
||||
"updated_at": "2025-12-01T10:30:00Z"
|
||||
"success": true,
|
||||
"message": "Tarefa atualizada com sucesso",
|
||||
"data": {
|
||||
"id": "6b1f2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
|
||||
"user_id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"title": "Fazer compras (atualizado)",
|
||||
"description": "Ir ao supermercado e padaria",
|
||||
"completed": true,
|
||||
"due_date": "2025-12-20T00:00:00Z",
|
||||
"category": "compras",
|
||||
"priority": "medium",
|
||||
"created_at": "2025-12-01T10:00:00Z",
|
||||
"updated_at": "2025-12-01T10:30:00Z"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Campos opcionais:**
|
||||
- Todos os campos de CreateTaskDto são opcionais em PATCH
|
||||
|
||||
**Erros:**
|
||||
- `404 Not Found` - Tarefa não encontrada
|
||||
- `400 Bad Request` - Dados inválidos
|
||||
@@ -267,6 +318,7 @@ Authorization: Bearer {token}
|
||||
**Response (200 OK):**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Tarefa deletada com sucesso"
|
||||
}
|
||||
```
|
||||
@@ -277,6 +329,31 @@ Authorization: Bearer {token}
|
||||
|
||||
---
|
||||
|
||||
#### 2.6 Obter Estatísticas
|
||||
```http
|
||||
GET /tasks/stats
|
||||
Authorization: Bearer {token}
|
||||
```
|
||||
|
||||
**Response (200 OK):**
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Estatísticas recuperadas com sucesso",
|
||||
"data": {
|
||||
"total": 10,
|
||||
"completed": 6,
|
||||
"pending": 4,
|
||||
"completionPercentage": 60
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Erros:**
|
||||
- `401 Unauthorized` - Token inválido
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Real-time (WebSocket)
|
||||
|
||||
### Conectar ao Realtime
|
||||
|
||||
Reference in New Issue
Block a user