mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-19 20:02:20 -06:00
refactor: integrations folder
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
import { ChatwootRouter } from '@api/integrations/chatbot/chatwoot/routes/chatwoot.router';
|
||||
import { DifyRouter } from '@api/integrations/chatbot/dify/routes/dify.router';
|
||||
import { OpenaiRouter } from '@api/integrations/chatbot/openai/routes/openai.router';
|
||||
import { TypebotRouter } from '@api/integrations/chatbot/typebot/routes/typebot.router';
|
||||
import { Router } from 'express';
|
||||
|
||||
export class ChatbotRouter {
|
||||
public readonly router: Router;
|
||||
|
||||
constructor(...guards: any[]) {
|
||||
this.router = Router();
|
||||
|
||||
this.router.use('/chatwoot', new ChatwootRouter(...guards).router);
|
||||
this.router.use('/typebot', new TypebotRouter(...guards).router);
|
||||
this.router.use('/openai', new OpenaiRouter(...guards).router);
|
||||
this.router.use('/dify', new DifyRouter(...guards).router);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import { RabbitmqRouter } from '@api/integrations/event/rabbitmq/routes/rabbitmq.router';
|
||||
import { SqsRouter } from '@api/integrations/event/sqs/routes/sqs.router';
|
||||
import { WebhookRouter } from '@api/integrations/event/webhook/routes/webhook.router';
|
||||
import { WebsocketRouter } from '@api/integrations/event/websocket/routes/websocket.router';
|
||||
import { Router } from 'express';
|
||||
|
||||
export class EventRouter {
|
||||
public readonly router: Router;
|
||||
|
||||
constructor(configService: any, ...guards: any[]) {
|
||||
this.router = Router();
|
||||
|
||||
this.router.use('/webhook', new WebhookRouter(configService, ...guards).router);
|
||||
this.router.use('/websocket', new WebsocketRouter(...guards).router);
|
||||
this.router.use('/rabbitmq', new RabbitmqRouter(...guards).router);
|
||||
this.router.use('/sqs', new SqsRouter(...guards).router);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,22 @@
|
||||
import { authGuard } from '@api/guards/auth.guard';
|
||||
import { instanceExistsGuard, instanceLoggedGuard } from '@api/guards/instance.guard';
|
||||
import Telemetry from '@api/guards/telemetry.guard';
|
||||
import { webhookController } from '@api/server.module';
|
||||
import { configService, WaBusiness } from '@config/env.config';
|
||||
import { ChatbotRouter } from '@api/integrations/chatbot/chatbot.router';
|
||||
import { EventRouter } from '@api/integrations/event/event.router';
|
||||
import { StorageRouter } from '@api/integrations/storage/storage.router';
|
||||
import { configService } from '@config/env.config';
|
||||
import { Router } from 'express';
|
||||
import fs from 'fs';
|
||||
import mime from 'mime';
|
||||
import path from 'path';
|
||||
|
||||
import { ChatRouter } from './chat.router';
|
||||
import { ChatbotRouter } from './chatbot.router';
|
||||
import { EventRouter } from './event.router';
|
||||
import { GroupRouter } from './group.router';
|
||||
import { InstanceRouter } from './instance.router';
|
||||
import { LabelRouter } from './label.router';
|
||||
import { ProxyRouter } from './proxy.router';
|
||||
import { MessageRouter } from './sendMessage.router';
|
||||
import { SettingsRouter } from './settings.router';
|
||||
import { StorageRouter } from './storage.router';
|
||||
import { TemplateRouter } from './template.router';
|
||||
import { ViewsRouter } from './view.router';
|
||||
|
||||
@@ -85,17 +84,6 @@ router
|
||||
.use('/settings', new SettingsRouter(...guards).router)
|
||||
.use('/proxy', new ProxyRouter(...guards).router)
|
||||
.use('/label', new LabelRouter(...guards).router)
|
||||
.get('/webhook/meta', async (req, res) => {
|
||||
if (req.query['hub.verify_token'] === configService.get<WaBusiness>('WA_BUSINESS').TOKEN_WEBHOOK)
|
||||
res.send(req.query['hub.challenge']);
|
||||
else res.send('Error, wrong validation token');
|
||||
})
|
||||
.post('/webhook/meta', async (req, res) => {
|
||||
const { body } = req;
|
||||
const response = await webhookController.receiveWebhook(body);
|
||||
|
||||
return res.status(200).json(response);
|
||||
})
|
||||
.use('', new EventRouter(configService, ...guards).router)
|
||||
.use('', new ChatbotRouter(...guards).router)
|
||||
.use('', new StorageRouter(...guards).router);
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { S3Router } from '@api/integrations/storage/s3/routes/s3.router';
|
||||
import { Router } from 'express';
|
||||
|
||||
export class StorageRouter {
|
||||
public readonly router: Router;
|
||||
|
||||
constructor(...guards: any[]) {
|
||||
this.router = Router();
|
||||
|
||||
this.router.use('/s3', new S3Router(...guards).router);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user