diff --git a/.github/ISSUE_TEMPLATE/-en--bug-report.md b/.github/ISSUE_TEMPLATE/-en--bug-report.md new file mode 100644 index 00000000..52579cb2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/-en--bug-report.md @@ -0,0 +1,38 @@ +--- +name: "[EN] Bug report" +about: Create a report to help us improve +title: "[EN][BUG]" +labels: bug +assignees: '' + +--- + +### Title: [Brief Description of the Bug] + +#### Description: +Describe in detail the problem you encountered. Include any relevant context that may help understand the origin of the bug. + +#### Steps to Reproduce: +1. List the steps necessary to reproduce the problem. +2. Try to be as specific as possible. +3. If the problem occurs in a specific scenario, describe it here. + +#### Expected Behavior: +Describe what you expected to happen when following the steps above. + +#### Current Behavior: +Explain what actually happens when you follow the steps above. + +#### Screenshots/Videos: +If possible, add screenshots or videos illustrating the problem. This can be extremely helpful in understanding the issue. + +#### Environment: +- **Server:** [e.g., Ubuntu 18.04] +- **API Version:** [e.g., 1.5.4] +- **Other Hardware/Software Specifications:** [e.g., CPU, GPU] + +#### Submitting Logs: +Please attach logs that may be related to the problem. If the logs contain sensitive information, consider sending them privately to one of the project maintainers. + +#### Additional Notes: +Include here any other information that you think might be useful in understanding or resolving the bug. diff --git a/.github/ISSUE_TEMPLATE/-en--feature-request.md b/.github/ISSUE_TEMPLATE/-en--feature-request.md new file mode 100644 index 00000000..df7959c6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/-en--feature-request.md @@ -0,0 +1,28 @@ +--- +name: "[EN] Feature request" +about: Suggest an idea for the API +title: "[EN][FEAT]" +labels: enhancement +assignees: '' + +--- + +### Title: [Brief Description of Feature Request] + +#### Detailed Description: +Clearly and in detail, describe the functionality you wish to be implemented. Explain how this fits into the context of the project. + +#### Rationale: +Explain why this functionality would be useful for the project. This helps in understanding the importance and priority of the request. + +#### Usage Examples: +Provide specific examples of how this feature could be used. This can include scenarios or use cases where the feature would be particularly beneficial. + +#### Possible Implementations: +If you have ideas on how this feature might be implemented, please share them here. This is not mandatory but can be helpful for the development team. + +#### Impact on the Project: +Discuss how this new feature could impact other parts of the project, if applicable. + +#### Additional Notes: +Any other information you believe is relevant to your request. diff --git a/.github/ISSUE_TEMPLATE/-pt--reportar-bug.md b/.github/ISSUE_TEMPLATE/-pt--reportar-bug.md new file mode 100644 index 00000000..7c99f991 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/-pt--reportar-bug.md @@ -0,0 +1,38 @@ +--- +name: "[PT] Reportar bug" +about: Reportar um problema +title: "[PT][BUG]" +labels: bug +assignees: '' + +--- + +### Título: [Breve Descrição do Bug] + +#### Descrição: +Descreva detalhadamente o problema que você encontrou. Inclua qualquer contexto relevante que possa ajudar a entender a origem do bug. + +#### Passos para Reproduzir: +1. Liste os passos necessários para reproduzir o problema. +2. Tente ser o mais específico possível. +3. Se o problema ocorrer em um cenário específico, descreva-o aqui. + +#### Comportamento Esperado: +Descreva o que você esperava que acontecesse quando seguisse os passos acima. + +#### Comportamento Atual: +Explique o que realmente acontece quando você segue os passos acima. + +#### Capturas de Tela/Vídeos: +Se possível, adicione capturas de tela ou vídeos que ilustrem o problema. Isso pode ser extremamente útil para entender o problema. + +#### Ambiente: +- **Servidor:** [ex: Ubuntu 18.04] +- **Versão da API:** [ex: 1.5.4] +- **Outras Especificações de Hardware/Software:** [ex: CPU, GPU] + +#### Envio de Logs: +Por favor, anexe os logs que possam estar relacionados ao problema. Se os logs contiverem informações sensíveis, considere enviá-los de forma privada para um dos mantenedores do projeto. + +#### Notas Adicionais: +Inclua aqui qualquer outra informação que você ache que possa ser útil para entender ou resolver o bug. diff --git a/.github/ISSUE_TEMPLATE/-pt--solicitar-recurso.md b/.github/ISSUE_TEMPLATE/-pt--solicitar-recurso.md new file mode 100644 index 00000000..900389fd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/-pt--solicitar-recurso.md @@ -0,0 +1,28 @@ +--- +name: "[PT] Solicitar recurso" +about: Sugira novos recursos para a API +title: "[PT][FEAT]" +labels: enhancement +assignees: '' + +--- + +### Título: [Breve Descrição da Solicitação de Recurso] + +#### Descrição Detalhada: +Descreva claramente e em detalhes a funcionalidade que você deseja que seja implementada. Explique como isso se encaixa no contexto do projeto. + +#### Racional: +Explique por que essa funcionalidade seria útil para o projeto. Isso ajuda a entender a importância e a prioridade da solicitação. + +#### Exemplos de Uso: +Forneça exemplos específicos de como essa funcionalidade poderia ser utilizada. Isso pode incluir cenários ou casos de uso onde a funcionalidade seria particularmente benéfica. + +#### Possíveis Implementações: +Se você tem ideias sobre como essa funcionalidade pode ser implementada, por favor, compartilhe-as aqui. Isso não é obrigatório, mas pode ser útil para a equipe de desenvolvimento. + +#### Impacto no Projeto: +Discuta como essa nova funcionalidade poderia impactar outras partes do projeto, se aplicável. + +#### Notas Adicionais: +Qualquer outra informação que você acredita ser relevante para a sua solicitação. diff --git a/.gitignore b/.gitignore index 2364b077..c55eb628 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ docker-compose.yaml /test/ /src/env.yml /store +*.env /temp/* diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b62084d..f6e5b396 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * Fixed the pairing code * Adjusts in typebot * Fix the problem when disconnecting the instance and connecting again using mongodb +* Options to disable docs and manager # 1.6.0 (2023-12-12 17:24) diff --git a/Docker/evolution-api-all-services/.env b/Docker/evolution-api-all-services/.env.example similarity index 100% rename from Docker/evolution-api-all-services/.env rename to Docker/evolution-api-all-services/.env.example diff --git a/src/config/env.config.ts b/src/config/env.config.ts index 45b8a5e1..511f4ebc 100644 --- a/src/config/env.config.ts +++ b/src/config/env.config.ts @@ -3,7 +3,13 @@ import { readFileSync } from 'fs'; import { load } from 'js-yaml'; import { join } from 'path'; -export type HttpServer = { TYPE: 'http' | 'https'; PORT: number; URL: string }; +export type HttpServer = { + TYPE: 'http' | 'https'; + PORT: number; + URL: string; + DISABLE_DOCS: boolean; + DISABLE_MANAGER: boolean; +}; export type HttpMethods = 'POST' | 'GET' | 'PUT' | 'DELETE'; export type Cors = { @@ -186,6 +192,8 @@ export class ConfigService { TYPE: (process.env.SERVER_TYPE as 'http' | 'https') || 'http', PORT: Number.parseInt(process.env.SERVER_PORT) || 8080, URL: process.env.SERVER_URL, + DISABLE_DOCS: process.env?.SERVER_DISABLE_DOCS === 'true', + DISABLE_MANAGER: process.env?.SERVER_DISABLE_MANAGER === 'true', }, CORS: { ORIGIN: process.env.CORS_ORIGIN.split(',') || ['*'], diff --git a/src/dev-env.yml b/src/dev-env.yml index 01a5927f..80c7e376 100644 --- a/src/dev-env.yml +++ b/src/dev-env.yml @@ -9,6 +9,9 @@ SERVER: TYPE: http # https PORT: 8080 # 443 URL: localhost + DISABLE_MANAGER: false + DISABLE_DOCS: false + CORS: ORIGIN: diff --git a/src/main.ts b/src/main.ts index 52bdd798..554d95e8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -53,7 +53,8 @@ function bootstrap() { app.use('/store', express.static(join(ROOT_DIR, 'store'))); app.use('/', router); - app.use(swaggerRouter); + + if (!configService.get('SERVER').DISABLE_DOCS) app.use(swaggerRouter); app.use( (err: Error, req: Request, res: Response, next: NextFunction) => { diff --git a/src/whatsapp/routers/index.router.ts b/src/whatsapp/routers/index.router.ts index 781b528c..56b9301f 100644 --- a/src/whatsapp/routers/index.router.ts +++ b/src/whatsapp/routers/index.router.ts @@ -31,23 +31,25 @@ enum HttpStatus { const router = Router(); const authType = configService.get('AUTHENTICATION').TYPE; +const serverConfig = configService.get('SERVER'); const guards = [instanceExistsGuard, instanceLoggedGuard, authGuard[authType]]; const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8')); +if (!serverConfig.DISABLE_MANAGER) router.use('/manager', new ViewsRouter().router); + router .get('/', (req, res) => { res.status(HttpStatus.OK).json({ status: HttpStatus.OK, message: 'Welcome to the Evolution API, it is working!', version: packageJson.version, - swagger: `${req.protocol}://${req.get('host')}/docs`, + swagger: !serverConfig.DISABLE_DOCS ? `${req.protocol}://${req.get('host')}/docs` : undefined, + manager: !serverConfig.DISABLE_MANAGER ? `${req.protocol}://${req.get('host')}/manager` : undefined, documentation: `https://doc.evolution-api.com`, - manager: `${req.protocol}://${req.get('host')}/manager`, }); }) .use('/instance', new InstanceRouter(configService, ...guards).router) - .use('/manager', new ViewsRouter().router) .use('/message', new MessageRouter(...guards).router) .use('/chat', new ChatRouter(...guards).router) .use('/group', new GroupRouter(...guards).router)