Open joelbrs opened 3 months ago
As mudanças introduzem a integração do Redis na arquitetura do aplicativo, melhorando a configuração do ambiente, a criação de transações e a gestão de contextos. Novas variáveis de ambiente para o Redis foram adicionadas, junto com um arquivo docker-compose
para serviços de desenvolvimento. O código foi refinado para eliminar a necessidade de chaves idempotentes, simplificando a lógica de criação de transações e aprimorando a estrutura de testes.
Arquivo | Resumo das mudanças |
---|---|
apps/server/.env.example |
Adição das variáveis de ambiente REDIS_HOST , REDIS_PORT e REDIS_PASSWORD ; NODE_ENV permanece inalterado. |
apps/server/docker-compose.dev.yml |
Introdução de configuração para serviços MongoDB e Redis em um ambiente de desenvolvimento, com comandos, health checks e volumes configurados. |
apps/server/package.json |
Adição da dependência ioredis na versão ^5.4.1 para suporte ao Redis. |
apps/server/src/config/environment.ts |
Expansão do esquema de configuração para incluir REDIS_HOST , REDIS_PORT e REDIS_PASSWORD , com NODE_ENV agora aceitando "test". |
apps/server/src/get-context.ts |
Remoção da propriedade idempotentKey da interface ContextVars e ajuste da função getContext para simplificação. |
apps/server/src/modules/transaction/__test__/create-transaction.spec.ts |
Reestruturação dos testes para CreateTransactionMutation , focando em validação de fundos e introduzindo novos casos de teste para duplicatas e contas inexistentes. |
apps/server/src/modules/transaction/fixtures/create-transaction.ts |
Remoção da atribuição de idempotentKey na função createTransaction , simplificando o processo de criação de transações. |
apps/server/src/modules/transaction/mutations/create-transaction.ts |
Alteração da lógica de idempotência para geração de chave baseada em hash, incluindo melhorias no tratamento de erros. |
apps/server/src/modules/transaction/transaction-model.ts |
Remoção do idempotentKey do tipo Transaction e do esquema Mongoose, simplificando a estrutura do modelo. |
apps/server/src/redis.ts |
Criação de um arquivo para gerenciar a conexão com o Redis, utilizando a biblioteca ioredis e variáveis de ambiente para configuração. |
sequenceDiagram
participant App as Aplicação
participant Redis as Redis
participant Mongo as MongoDB
App->>Redis: Solicita conexão
Redis-->>App: Retorna cliente Redis
App->>Mongo: Cria transação
Mongo-->>App: Retorna ID da transação
App->>Redis: Gera chave de idempotência
Redis-->>App: Armazena estado da transação com expiração
🐰 "Em um bosque florido, eu me alegro a saltar,
Com Redis agora, tudo vai acelerar!
Transações mais leves, sem chave a pesar,
No mundo digital, vamos juntos dançar!
Um brinde ao progresso, vamos celebrar!" 🌼
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
The latest updates on your projects. Learn more about Vercel for Git ↗︎