docs: atualiza README com url de producao e doc Swagger

This commit is contained in:
2026-04-28 19:05:22 -05:00
parent 80262c4be3
commit 5b53211727

View File

@@ -16,7 +16,13 @@ MVP de autenticação central para serviços distribuídos.
- Prisma + Postgres - Prisma + Postgres
- JOSE (JWT) - JOSE (JWT)
## Setup ## Produção
**Base URL:** `https://sistema-distribuido-trabalho-faculd.vercel.app`
**Documentação interativa (Swagger):** [`/docs`](https://sistema-distribuido-trabalho-faculd.vercel.app/docs)
## Setup local
1. Instale dependências: 1. Instale dependências:
@@ -56,7 +62,7 @@ npm run dev
## Usuários de seed ## Usuários de seed
- `student@example.com` / `123456` - `student@example.com` / `123456`
s
## Estrutura da tabela `User` ## Estrutura da tabela `User`
A tabela `User` possui apenas: A tabela `User` possui apenas:
@@ -69,13 +75,15 @@ A tabela `User` possui apenas:
## Endpoints ## Endpoints
- `POST /auth/login` | Método | Caminho | Auth | Descrição |
- `POST /auth/refresh` |--------|---------|------|-----------|
- `POST /auth/register` | POST | `/api/auth/register` | Não | Cria novo usuário |
- `POST /auth/forgot-password` | POST | `/api/auth/login` | Não | Autentica e retorna tokens |
- `POST /auth/reset-password` | POST | `/api/auth/refresh` | Não | Rotaciona refresh token |
- `GET /profile/me` (protegida) | POST | `/api/auth/forgot-password` | Não | Solicita reset de senha |
- `GET /dashboard` (protegida, chama `/profile/me`) | POST | `/api/auth/reset-password` | Não | Aplica nova senha com token |
| GET | `/profile/me` | Sim (Bearer) | Retorna usuário autenticado |
| GET | `/dashboard` | Sim (Bearer) | Orquestração A→B |
## Guia para serviços consumidores ## Guia para serviços consumidores
@@ -98,7 +106,7 @@ A identidade confiável do usuário é sempre o `sub`.
### 1) Cadastro ### 1) Cadastro
```bash ```bash
curl -X POST http://localhost:3000/auth/register \ curl -X POST https://sistema-distribuido-trabalho-faculd.vercel.app/api/auth/register \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d '{"email":"novo.usuario@example.com","password":"senha123"}' -d '{"email":"novo.usuario@example.com","password":"senha123"}'
``` ```
@@ -108,7 +116,7 @@ Fluxo recomendado no cliente: `register -> login`.
### 2) Login ### 2) Login
```bash ```bash
curl -X POST http://localhost:3000/auth/login \ curl -X POST https://sistema-distribuido-trabalho-faculd.vercel.app/api/auth/login \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d '{"email":"novo.usuario@example.com","password":"senha123"}' -d '{"email":"novo.usuario@example.com","password":"senha123"}'
``` ```
@@ -116,17 +124,17 @@ curl -X POST http://localhost:3000/auth/login \
### 3) Forgot password (sem SMTP, modo didático) ### 3) Forgot password (sem SMTP, modo didático)
```bash ```bash
curl -X POST http://localhost:3000/auth/forgot-password \ curl -X POST https://sistema-distribuido-trabalho-faculd.vercel.app/api/auth/forgot-password \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d '{"email":"novo.usuario@example.com"}' -d '{"email":"novo.usuario@example.com"}'
``` ```
Observação: neste MVP didático a resposta já traz `recovery.reset_token` e `recovery.reset_url`. Observação: neste MVP a resposta já traz `recovery.reset_token` e `recovery.reset_url`.
### 4) Reset password ### 4) Reset password
```bash ```bash
curl -X POST http://localhost:3000/auth/reset-password \ curl -X POST https://sistema-distribuido-trabalho-faculd.vercel.app/api/auth/reset-password \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d '{"token":"<reset_token>","new_password":"novaSenha123"}' -d '{"token":"<reset_token>","new_password":"novaSenha123"}'
``` ```
@@ -134,7 +142,7 @@ curl -X POST http://localhost:3000/auth/reset-password \
### 5) Login com nova senha ### 5) Login com nova senha
```bash ```bash
curl -X POST http://localhost:3000/auth/login \ curl -X POST https://sistema-distribuido-trabalho-faculd.vercel.app/api/auth/login \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d '{"email":"novo.usuario@example.com","password":"novaSenha123"}' -d '{"email":"novo.usuario@example.com","password":"novaSenha123"}'
``` ```
@@ -142,21 +150,21 @@ curl -X POST http://localhost:3000/auth/login \
### 6) Rota protegida ### 6) Rota protegida
```bash ```bash
curl http://localhost:3000/profile/me \ curl https://sistema-distribuido-trabalho-faculd.vercel.app/profile/me \
-H "Authorization: Bearer <access_token>" -H "Authorization: Bearer <access_token>"
``` ```
### 7) Chamada entre serviços (A -> B) ### 7) Chamada entre serviços (A -> B)
```bash ```bash
curl http://localhost:3000/dashboard \ curl https://sistema-distribuido-trabalho-faculd.vercel.app/dashboard \
-H "Authorization: Bearer <access_token>" -H "Authorization: Bearer <access_token>"
``` ```
### 8) Refresh ### 8) Refresh
```bash ```bash
curl -X POST http://localhost:3000/auth/refresh \ curl -X POST https://sistema-distribuido-trabalho-faculd.vercel.app/api/auth/refresh \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d '{"refresh_token":"<refresh_token>"}' -d '{"refresh_token":"<refresh_token>"}'
``` ```