Hexagonal, mejora del cliente RMQ y tipos de eventos

This commit is contained in:
2026-01-13 15:41:59 +01:00
parent a6abc24e5f
commit d2db2062b0
20 changed files with 517 additions and 100 deletions

View File

@@ -0,0 +1,42 @@
import { EventBus } from "../../shared/domain/EventBus.port";
import { SimEvents } from "../../shared/domain/SimEvents";
/**
* TODO:
* - Conexion con la BDD
* - Conexion con RabbitMQ
* - Pasar a clase cuando existan las conexiones
*/
export class SimUsecases {
private eventBus: EventBus
constructor(args: {
eventBus: EventBus
}
) {
this.eventBus = args.eventBus
}
async activation(args: { iccid: string }) {
const activationEvent = <SimEvents.activation>{
key: "sim.activation",
payload: {
iccid: args.iccid
}
}
return this.eventBus.publish([activationEvent])
}
cancelation(args: { iccid: string }) {
throw new Error("Function not implemented.");
}
pause(args: { iccid: string }) {
throw new Error("Function not implemented.");
}
free(args: { iccid: string }) {
throw new Error("Function not implemented.");
}
}

View File

@@ -0,0 +1,37 @@
import { Request, Response } from "express"
import { SimUsecases } from "aplication/Sim.usecases"
export class SimController {
private simUseCases: SimUsecases
constructor(args: {
simUseCases: SimUsecases
}) {
this.simUseCases = args.simUseCases
}
async activation(req: Request, res: Response) {
const { iccid } = req.body
if (iccid == undefined) {
// TODO: excepcion con nombre se va a repetir
res.status(400).json({
msg: "iccid invalido"
})
}
const resp = await this.simUseCases.activation({ iccid })
}
cancelation(req: Request, res: Response) {
}
pause(req: Request, res: Response) {
}
free(req: Request, res: Response) {
}
}