Conversation
There was a problem hiding this comment.
Pull request overview
This PR modernizes the service build/runtime to TypeScript + ESM (NodeNext), migrates the WhatsApp integration to Baileys with new management endpoints, and adds supporting infrastructure (email templating, process scripts, Prisma models/migrations, and logging).
Changes:
- Switch to ESM/NodeNext TypeScript build output under
dist/, with a newserver.tsentrypoint. - Replace WhatsApp Web client implementation with a Baileys-based implementation, plus new WhatsApp routes/controllers/services (status/connect/list/delete).
- Add email templating via
@react-email/*, a key generation service persisted in Prisma, and new process-management scripts.
Reviewed changes
Copilot reviewed 33 out of 52 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Updates TS target/module settings for ESM (NodeNext) and dist output. |
| src/services/whatsapp.service.ts | Adds message listing/deletion and bot status/connect/stop behavior. |
| src/services/key.service.ts | Adds API key generation + persistence + admin email notification. |
| src/services/email.service.ts | Replaces JS email service with TS version using React Email templates. |
| src/services/email.service.js | Removes old JS email service implementation. |
| src/scripts/stop-microservice.ts | Adds script to stop detached microservice process. |
| src/scripts/start-pm2-notify.ts | Adds script to build and start service via PM2. |
| src/scripts/start-microservice.ts | Adds script to start detached microservice process. |
| src/scripts/process-utils.ts | Adds cross-platform-ish helpers for detached process start/stop and command execution. |
| src/scripts/delete-whatsapp-session.ts | Adds script to delete Baileys session folder. |
| src/scripts/connect-whatsapp.ts | Adds script to start WhatsApp connection flow and clean up on signals. |
| src/routes/whatsapp.route.ts | Adds expanded WhatsApp API routes (messages, status, connect/start/stop). |
| src/routes/whatsapp.route.js | Removes old JS WhatsApp routes. |
| src/routes/routes.ts | Adds root router wiring for WhatsApp/email + ping endpoints. |
| src/routes/email.route.ts | Adds email route for test endpoint. |
| src/logs/logs.log | Adds a committed log file (contains runtime data). |
| src/logs/logger.ts | Introduces pino logger writing to a file destination. |
| src/infra/whatsapp/whatsapp_web.js | Removes WhatsApp Web client implementation. |
| src/infra/whatsapp/baileys.ts | Adds Baileys-based WhatsApp bot implementation and status reporting. |
| src/infra/whatsapp/baileys.js | Removes old JS Baileys implementation. |
| src/infra/index.ts | Adds infra barrel exporting WhatsApp + email transporter. |
| src/infra/index.js | Removes old infra index using WhatsApp Web. |
| src/infra/email/templates/baseEmailTemplate.ts | Adds base React Email template component. |
| src/infra/email/email.ts | Adds nodemailer transport config. |
| src/env.ts | Adds centralized env accessor. |
| src/controller/whatsapp.controller.ts | Adds new WhatsApp controllers for list/delete/connect/status. |
| src/controller/whatsapp.controller.js | Removes old JS WhatsApp controller. |
| src/controller/email.controller.ts | Minor export formatting adjustment (keeps TS controller). |
| src/common/humanization.ts | Adds message “humanization” helpers (delays + random greeting). |
| src/common/defaultResponse.ts | Adds default response map helper. |
| src/app.ts | Fixes routes import path and adds dashboard static/file routes. |
| server.ts | Adds dist entrypoint that imports the app. |
| prisma/schema.prisma | Adds Keys model alongside Message. |
| prisma/prisma.ts | Adds Prisma client initialization using better-sqlite3 adapter. |
| prisma/migrations/migration_lock.toml | Adds Prisma migrations lock (sqlite provider). |
| prisma/migrations/20260409174050_key/migration.sql | Adds migration for Keys table. |
| prisma/migrations/20260407195917_init/migration.sql | Adds initial migration for Message table. |
| prisma/generated/prisma/schema.prisma | Updates generated schema to include Keys. |
| prisma/generated/prisma/package.json | Updates generated Prisma client package metadata. |
| prisma/generated/prisma/index.js | Updates generated Prisma client runtime exports for Keys. |
| prisma/generated/prisma/index.d.ts | Updates generated Prisma client types for Keys. |
| prisma/generated/prisma/index-browser.js | Updates generated browser bundle exports for Keys. |
| prisma/generated/prisma/edge.js | Updates generated edge bundle exports for Keys. |
| package.json | Updates entrypoint, build/dev scripts, ESM type, and dependencies. |
| package-lock.json | Updates lockfile for new deps (react-email, baileys rc13, etc.). |
| logs/logger.js | Removes old logger implementation at repo root. |
| docs/whatsapp.md | Removes WhatsApp route documentation file. |
| docs/doc.md | Removes general project documentation file. |
| .gitignore | Updates ignored paths (adds dist, changes sqlite db ignore, etc.). |
| .env.example | Updates example env vars (sqlite DATABASE_URL and root creds). |
Comments suppressed due to low confidence (1)
src/app.ts:9
- O app passa a servir "/dashboard" e assets de "src/views", mas esse diretório não existe no repositório (nem será copiado pelo tsc). Isso deixa a rota quebrada em runtime e pode causar erro/404 ao acessar o dashboard.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3
to
+8
| export const logger = pino( | ||
| pino.destination({ | ||
| dest: './src/logs/logs.log', | ||
| mkdir: true, | ||
| sync: false | ||
| }) |
Comment on lines
19
to
23
| "devDependencies": { | ||
| "@types/better-sqlite3": "^7.6.13", | ||
| "@types/node": "^25.0.3", | ||
| "prisma": "^7.2.0", | ||
| "tsup": "^8.5.1", | ||
| "tsx": "^4.21.0", | ||
| "tsx": "^4.20.6", | ||
| "typescript": "^5.9.3" | ||
| }, |
| "scripts": { | ||
| "dev": "cross-env NODE_ENV=development node app.js", | ||
| "start": "cross-env NODE_ENV=production node app.js" | ||
| "build": "tsc && robocopy prisma\\generated dist\\prisma\\generated /E >NUL & if %ERRORLEVEL% LEQ 7 exit 0 else exit %ERRORLEVEL%", |
| "express": "^5.2.1", | ||
| "format": "^0.2.2", | ||
| "helmet": "^8.1.0", | ||
| "inquirer": "^13.4.0", |
| "qrcode-terminal": "^0.12.0", | ||
| "react": "^19.2.4", | ||
| "react-dom": "^19.2.4", | ||
| "whatsapp-web.js": "^1.34.6" |
Comment on lines
+54
to
+56
| const status = await stopWhatsappBotService(); | ||
| return res.status(200).json({ message: "Bot do WhatsApp parado com sucesso!", data: status }); | ||
| } |
Comment on lines
+70
to
+73
| function getWhatsappBotStatus(req, res) { | ||
| const status = getWhatsappBotStatusService(); | ||
| return res.status(200).json({ data: status }); | ||
| } |
| if (apiKey && message) { | ||
| await prismaManager.keys.create({ | ||
| data: { | ||
| value: apiKey, |
Comment on lines
5
to
+8
| EMAIL_USER= | ||
| EMAIL_WARNING= | ||
| EMAIL_PASS= | ||
| EMAIL_REMETENTE= No newline at end of file | ||
| EMAIL_REMETENTE= |
Comment on lines
+19
to
+21
| router.get("/start", startWhatsappBot); | ||
| router.post("/start", startWhatsappBot); | ||
| router.get("/status", getWhatsappBotStatus); |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.