- Updated type definitions in ChatWindow and MessageList components for better type safety. - Improved MessageInput to handle message responses, including a preview feature for replying to messages. - Enhanced the chat message handling logic to support message references and improve user interaction. - Refactored notification utility functions to support push notifications and rate limiting for email sending. - Updated backend schema to accommodate new features related to message responses and notifications.
78 lines
2.5 KiB
Markdown
78 lines
2.5 KiB
Markdown
# ⚙️ Configuração de Variáveis de Ambiente
|
|
|
|
## Passo 1: Configurar VAPID Keys no Convex
|
|
|
|
### Opção A: Via Dashboard Convex (Recomendado)
|
|
|
|
1. Acesse https://dashboard.convex.dev
|
|
2. Selecione seu projeto SGSE
|
|
3. Vá em **Settings** > **Environment Variables**
|
|
4. Clique em **Add Variable** e adicione uma por vez:
|
|
|
|
**Variável 1:**
|
|
- **Name**: `VAPID_PUBLIC_KEY`
|
|
- **Value**: `BDerX0lK_hBCLpC7EbuxoJb2EJ7bcCLaHWxkNumVbvrx9w0MmJduHxJOP3WBwBP-SpQGcueMOyHCv7LFK3KnQks`
|
|
|
|
**Variável 2:**
|
|
- **Name**: `VAPID_PRIVATE_KEY`
|
|
- **Value**: `KWkJLMxCuCPQQiRXIJEt06G4pTdW0FaUN_vMyY02sc4`
|
|
|
|
**Variável 3:**
|
|
- **Name**: `FRONTEND_URL`
|
|
- **Value**: `http://localhost:5173` (ou sua URL de produção)
|
|
|
|
### Opção B: Via CLI Convex
|
|
|
|
Execute os seguintes comandos no diretório `packages/backend`:
|
|
|
|
```bash
|
|
cd packages/backend
|
|
|
|
# Configurar VAPID Public Key
|
|
npx convex env set VAPID_PUBLIC_KEY "BDerX0lK_hBCLpC7EbuxoJb2EJ7bcCLaHWxkNumVbvrx9w0MmJduHxJOP3WBwBP-SpQGcueMOyHCv7LFK3KnQks"
|
|
|
|
# Configurar VAPID Private Key
|
|
npx convex env set VAPID_PRIVATE_KEY "KWkJLMxCuCPQQiRXIJEt06G4pTdW0FaUN_vMyY02sc4"
|
|
|
|
# Configurar URL do Frontend
|
|
npx convex env set FRONTEND_URL "http://localhost:5173"
|
|
```
|
|
|
|
## Passo 2: Configurar VAPID Public Key no Frontend
|
|
|
|
Crie um arquivo `.env` no diretório `apps/web/` com o seguinte conteúdo:
|
|
|
|
```env
|
|
VITE_VAPID_PUBLIC_KEY=BDerX0lK_hBCLpC7EbuxoJb2EJ7bcCLaHWxkNumVbvrx9w0MmJduHxJOP3WBwBP-SpQGcueMOyHCv7LFK3KnQks
|
|
```
|
|
|
|
**Importante**:
|
|
- Após criar/modificar o `.env`, reinicie o servidor de desenvolvimento do frontend
|
|
- O arquivo `.env` já está no `.gitignore`, então não será commitado
|
|
|
|
## Passo 3: Verificar Configuração
|
|
|
|
### Verificar no Convex Dashboard:
|
|
1. Acesse https://dashboard.convex.dev
|
|
2. Vá em **Settings** > **Environment Variables**
|
|
3. Verifique se as 3 variáveis estão listadas
|
|
|
|
### Verificar no Frontend:
|
|
1. Execute o frontend: `cd apps/web && bun run dev`
|
|
2. Abra o DevTools (F12)
|
|
3. Vá em **Console** e execute: `console.log(import.meta.env.VITE_VAPID_PUBLIC_KEY)`
|
|
4. Deve exibir a chave pública (ou `undefined` se não estiver configurado)
|
|
|
|
## Chaves Geradas
|
|
|
|
As seguintes VAPID keys foram geradas para este projeto:
|
|
|
|
- **Public Key**: `BDerX0lK_hBCLpC7EbuxoJb2EJ7bcCLaHWxkNumVbvrx9w0MmJduHxJOP3WBwBP-SpQGcueMOyHCv7LFK3KnQks`
|
|
- **Private Key**: `KWkJLMxCuCPQQiRXIJEt06G4pTdW0FaUN_vMyY02sc4`
|
|
|
|
⚠️ **IMPORTANTE**:
|
|
- A Private Key deve ser mantida em segredo
|
|
- Nunca exponha a Private Key no frontend ou em código público
|
|
- Se suspeitar de comprometimento, regenere as keys com `bunx web-push generate-vapid-keys`
|
|
|