Commit Graph

10 Commits

Author SHA1 Message Date
Judson Cairo
32e58debc6 Path mapping & deps fix & bundler changed to tsup 2024-08-11 20:47:17 -03:00
Davidson Gomes
e3a97d0071 refactor: using stream instead of temp files in chatwoot and repository services
This commit refactors the code in the `chatwoot.service.ts` and `repository.service.ts` files to use streams instead of temporary files. This change reduces the number of disk operations, making the application faster and more efficient.

In the `chatwoot.service.ts` file, the `createReadStream`, `unlinkSync`, and `writeFileSync` functions have been replaced with the `Readable` stream. The `sendData` method has been updated to accept a `fileStream` and `fileName` instead of a file path. The `processImage` method has been refactored to use a stream instead of writing the image to a file.

In the `repository.service.ts` file, the `initStoreFolders` method has been removed, as it is no longer needed.

These changes improve the maintainability of the codebase by reducing the number of disk operations and simplifying the code. This refactoring also makes the application more efficient and faster, as it reduces the number of disk operations.

Motivation:
The motivation behind this refactoring is to improve the performance and efficiency of the application by reducing the number of disk operations.

Impact:
This refactoring reduces the number of disk operations, making the application faster and more efficient. It also simplifies the codebase and improves its maintainability.
2024-07-13 08:10:36 -03:00
Davidson Gomes
634ee9b4b3 fix: Resolve 'no such file or directory' error (#123)
This commit fixes an issue where a 'no such file or directory' error was being thrown. The error was caused by the absence of a temporary directory used for storing data. To resolve this issue, the `initStoreFolders` method was added to the `PrismaRepository` class, which creates the necessary store path and temporary directory during initialization.

The modifications include changes to the `repository.service.ts` file, where the `initStoreFolders` method was implemented. The `fs` and `path` modules were imported to facilitate file system operations.

With these changes, the error should no longer occur, ensuring the proper functioning of the application.
2024-07-12 14:01:18 -03:00
Davidson Gomes
228dcf8aa5 chore: Improve code consistency and readability
Refactored the initialization of `LocalSettings` in `channel.service.ts` to only set the properties that have been explicitly provided. This refactoring improves code consistency and readability. Also, removed the unused `initStoreFolders` method from `repository.service.ts` and its related imports. In addition, updated the import style for `PrismaClient` in `repository.service.ts`.

The modified files are:
- src/api/controllers/instance.controller.ts
- src/api/repository/repository.service.ts
- src/api/services/channel.service.ts
- src/api/services/channels/whatsapp.baileys.service.ts
2024-06-27 09:01:02 -03:00
Davidson Gomes
7ebf237c1c fix: init store folders 2024-06-10 11:28:28 -03:00
Davidson Gomes
36ec67cef9 feat: prisma and remove mongodb 2024-06-06 14:47:58 -03:00
Davidson Gomes
272bed1351 feat: prisma 2024-06-06 01:08:24 -03:00
Davidson Gomes
2fcb476c50 Now in the manager, when logging in with the client's apikey, the listing only shows the instance corresponding to the provided apikey (only with MongoDB) 2024-05-23 11:30:47 -03:00
Davidson Gomes
94f5c130bf fix: reorganization of files and folders 2024-04-12 17:22:11 -03:00
Davidson Gomes
8ece6fb998 fix: reorganization of files and folders 2024-04-12 17:13:15 -03:00