skailan-conversations
Version:
Servicio de conversaciones y mensajería para Skailan
37 lines • 2.86 kB
JavaScript
import { Router } from "express";
import { ChannelController } from "../controllers/channelController";
import { CreateChannel } from "../../app/use-cases/CreateChannel";
import { UpdateChannel } from "../../app/use-cases/UpdateChannel";
import { ConfigureTelegramChannel } from "../../app/use-cases/ConfigureTelegramChannel";
export function createChannelRoutes(channelRepository) {
const router = Router();
// Crear instancias de use cases
const createChannelUseCase = new CreateChannel(channelRepository);
const updateChannelUseCase = new UpdateChannel(channelRepository);
const configureTelegramChannelUseCase = new ConfigureTelegramChannel(channelRepository);
// Crear instancia del controlador
const channelController = new ChannelController(channelRepository, createChannelUseCase, updateChannelUseCase, configureTelegramChannelUseCase);
// Rutas para canales
// GET /organizations/:organizationId/channels - Obtener todos los canales
router.get("/organizations/:organizationId/channels", (req, res) => channelController.getChannels(req, res));
// GET /organizations/:organizationId/channels/type - Obtener canal por tipo
router.get("/organizations/:organizationId/channels/type", (req, res) => channelController.getChannelsByType(req, res));
// POST /organizations/:organizationId/channels - Crear nuevo canal
router.post("/organizations/:organizationId/channels", (req, res) => channelController.createChannel(req, res));
// GET /organizations/:organizationId/channels/:id - Obtener canal específico
router.get("/organizations/:organizationId/channels/:id", (req, res) => channelController.getChannel(req, res));
// PUT /organizations/:organizationId/channels/:id - Actualizar canal
router.put("/organizations/:organizationId/channels/:id", (req, res) => channelController.updateChannel(req, res));
// DELETE /organizations/:organizationId/channels/:id - Eliminar canal
router.delete("/organizations/:organizationId/channels/:id", (req, res) => channelController.deleteChannel(req, res));
// Configuración específica de Telegram
// POST /organizations/:organizationId/channels/:id/configure-telegram
router.post("/organizations/:organizationId/channels/:id/configure-telegram", (req, res) => channelController.configureTelegramChannel(req, res));
// Activación/Desactivación de canales
// POST /organizations/:organizationId/channels/:id/activate
router.post("/organizations/:organizationId/channels/:id/activate", (req, res) => channelController.activateChannel(req, res));
// POST /organizations/:organizationId/channels/:id/deactivate
router.post("/organizations/:organizationId/channels/:id/deactivate", (req, res) => channelController.deactivateChannel(req, res));
return router;
}
//# sourceMappingURL=channelRoutes.js.map