-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEAT: Projeto de backend reescrito de JavaScript para Typescript (#61)
* feat: instala alguns pacotes para o backend * feat: ajusta alguns componentes * feat: altera todos os arquivos do projeto backend para typescript * feat: adiciona os changesets
- Loading branch information
1 parent
9cda398
commit abe1ffc
Showing
30 changed files
with
588 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"qa-solar": patch | ||
--- | ||
|
||
chore: instala pacotes para o projeto backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"frontend": patch | ||
--- | ||
|
||
feat: ajusta alguns componentes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
"backend": major | ||
--- | ||
|
||
feat: migra o projeto de JavaScript para TypeScript | ||
|
||
BREAKING CHANGE: | ||
|
||
### O que mudou: | ||
- Todo o código do backend foi reescrito de JavaScript para TypeScript. | ||
- Foram adicionados tipos para garantir maior segurança e previsibilidade no código. | ||
- Algumas estruturas e middlewares foram refatorados para aderir às melhores práticas do TypeScript. | ||
|
||
### Por que a mudança foi feita: | ||
- Para melhorar a qualidade do código e reduzir erros em tempo de execução. | ||
- Para facilitar a manutenção do projeto e a escalabilidade futura. | ||
- Para alinhar o projeto com padrões modernos de desenvolvimento. | ||
|
||
### Como atualizar seu código: | ||
1. Certifique-se de ter o TypeScript instalado no seu ambiente de desenvolvimento. | ||
2. Atualize os comandos de execução do projeto para usar `ts-node` ou compile os arquivos com `tsc`. | ||
3. Verifique suas integrações externas para ajustar chamadas e tipos, se necessário. | ||
4. Revise os exemplos no `README.md` (se aplicável) para garantir compatibilidade com o novo código. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
if (!process.env.JWT_SECRET) { | ||
throw new Error('JWT_SECRET não definido no arquivo .env'); | ||
} | ||
|
||
export const JWT_SECRET = process.env.JWT_SECRET; |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
import { Request, Response } from 'express'; | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
export async function deleteUser(req: Request, res: Response): Promise<void> { | ||
const { ids } = req.body; | ||
|
||
if (ids.includes(req.userId)) { | ||
res.status(400).json({ message: 'Você não pode excluir o usuário logado.' }); | ||
return | ||
} | ||
|
||
try { | ||
const deletedUsers = await prisma.user.deleteMany({ | ||
where: { | ||
id: { in: ids }, | ||
}, | ||
}); | ||
|
||
if (deletedUsers.count === 0) { | ||
res.status(404).json({ message: 'Nenhum usuário encontrado para excluir.' }); | ||
return | ||
} | ||
|
||
res.status(200).json({ message: `${deletedUsers.count} usuário(s) excluído(s) com sucesso!` }); | ||
} catch (error) { | ||
res.status(500).json({ message: 'Erro ao excluir o usuário.' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
backend/src/controllers/logoutUser.js → backend/src/controllers/logoutUser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
export async function logoutUser(req, res) { | ||
import { Request, Response } from 'express'; | ||
|
||
export async function logoutUser(req: Request, res: Response): Promise<void> { | ||
try { | ||
const userId = req.userId; | ||
|
||
res.status(200).json({ message: `Logout realizado com sucesso do usuário com o ID: ${userId}` }); | ||
} catch (error) { | ||
res.status(500).json({ message: `Erro ao processar o logout do usuário com o ID: ${userId}` }); | ||
res.status(500).json({ message: `Erro ao processar o logout do usuário` }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
backend/src/controllers/updateUser.js → backend/src/controllers/updateUser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.