diff --git a/README.md b/README.md index 7b88bfd..28020d2 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,13 @@ MVP de autenticação central para serviços distribuídos. - Prisma + Postgres - 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: @@ -56,7 +62,7 @@ npm run dev ## Usuários de seed - `student@example.com` / `123456` -s + ## Estrutura da tabela `User` A tabela `User` possui apenas: @@ -69,13 +75,15 @@ A tabela `User` possui apenas: ## Endpoints -- `POST /auth/login` -- `POST /auth/refresh` -- `POST /auth/register` -- `POST /auth/forgot-password` -- `POST /auth/reset-password` -- `GET /profile/me` (protegida) -- `GET /dashboard` (protegida, chama `/profile/me`) +| Método | Caminho | Auth | Descrição | +|--------|---------|------|-----------| +| POST | `/api/auth/register` | Não | Cria novo usuário | +| POST | `/api/auth/login` | Não | Autentica e retorna tokens | +| POST | `/api/auth/refresh` | Não | Rotaciona refresh token | +| POST | `/api/auth/forgot-password` | Não | Solicita reset de senha | +| 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 @@ -98,7 +106,7 @@ A identidade confiável do usuário é sempre o `sub`. ### 1) Cadastro ```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' \ -d '{"email":"novo.usuario@example.com","password":"senha123"}' ``` @@ -108,7 +116,7 @@ Fluxo recomendado no cliente: `register -> login`. ### 2) Login ```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' \ -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) ```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' \ -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 ```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' \ -d '{"token":"","new_password":"novaSenha123"}' ``` @@ -134,7 +142,7 @@ curl -X POST http://localhost:3000/auth/reset-password \ ### 5) Login com nova senha ```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' \ -d '{"email":"novo.usuario@example.com","password":"novaSenha123"}' ``` @@ -142,21 +150,21 @@ curl -X POST http://localhost:3000/auth/login \ ### 6) Rota protegida ```bash -curl http://localhost:3000/profile/me \ +curl https://sistema-distribuido-trabalho-faculd.vercel.app/profile/me \ -H "Authorization: Bearer " ``` ### 7) Chamada entre serviços (A -> B) ```bash -curl http://localhost:3000/dashboard \ +curl https://sistema-distribuido-trabalho-faculd.vercel.app/dashboard \ -H "Authorization: Bearer " ``` ### 8) Refresh ```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' \ -d '{"refresh_token":""}' ```