{{ message }}
Repository navigation
Commit 6bb98d6
refactor: Fase 1 — padronização de handlers, classes de erro e imports ESM (#794)
* refactor: use return response.status(N).json() in handlers
Converte o padrão `response.status(N); response.json(data)` (separado,
sem return) para `return response.status(N).json(data)` (encadeado, com
return) em 15 handlers.
Previne execução acidental após o envio da resposta e adota o padrão
já usado pelo restante do projeto.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(banks): throw NotFoundError instead of direct response
Substitui response.status(404).json() direto por throw new NotFoundError(),
delegando a formatação da resposta ao middleware errorHandler.
A resposta agora inclui o campo `name: 'NotFoundError'`, consistente com
todos os outros endpoints de erro do projeto.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(feriados): throw BadRequestError instead of direct response
Substitui response.status(400).json() direto por throw new BadRequestError(),
delegando a formatação da resposta ao middleware errorHandler.
Preserva type: 'validation_error' para manter compatibilidade com o contrato
da API. Atualiza o teste para incluir name: 'BadRequestError', agora presente
pois a resposta passa pelo errorHandler padrão.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor: convert CommonJS require() to ESM import in services
Converte require() para import ESM em 3 arquivos de serviço que misturavam
sintaxe CommonJS com exports ESM:
- services/cambio/moedas.js (axios)
- services/cvm/corretoras.js (adm-zip, axios)
- services/date.js (dayjs e plugins utc/timezone)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: add docs/superpowers/ to .gitignore
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(tests): corrige imports de fundos-v1 para ESM e vitest
O arquivo usava `require('axios')` (CommonJS) e chamava `expect.extend()`
sem importar `expect` do vitest. Com `globals: false` no vitest config, isso
causava `ReferenceError: expect is not defined` e derrubava toda a suite.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(lint): corrige erros ESLint/Prettier que bloqueavam o next build
- feriados/v1: remove params não utilizados após conversão para throw
- cptec/previsao/semana: remove import InternalError não utilizado
- ibge/municipios: ajusta formatação Prettier em ALLOWED_PROVIDERS e unknown
- ibge/uf: reformata import para múltiplas linhas conforme Prettier
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: corrige IBGE UF e timeout do CEP no ambiente preview
- ibge/uf/v1: desestruturação errada `{ ufData }` sobre resposta axios
que possui `{ data }` — ufData era sempre undefined, causando 404
para qualquer UF válida. Produção mascarava o bug via CDN cache.
- cep/cep.js: cep-promise usava timeout padrão de 30s por provider.
Para CEPs inexistentes, Promise.any aguarda todos falharem (~30s),
estourando o limite de 10s do Vercel. Reduzido para 5s.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent e22d750 commit 6bb98d6
27 files changed
Lines changed: 42 additions & 55 deletions
File tree
- pages/api
- banks/v1
- cptec/v1
- cidade
- clima
- aeroporto
- previsao/semana/[lat]
- ondas/[cityCode]
- cvm
- corretoras/v1
- fundos/v1
- feriados/v1
- ibge
- municipios/v1
- uf/v1
- pix/v1
- status/v1
- taxas/v1
- tickers/b3
- acoes/v1
- fundos/v1
- services
- cambio
- cep
- cvm
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | 17 | | |
20 | 18 | | |
21 | | - | |
22 | | - | |
| 19 | + | |
23 | 20 | | |
24 | 21 | | |
25 | 22 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
| 30 | + | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
| 55 | + | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||

0 commit comments