Ajuste para enrutar por compañia y actividad

This commit is contained in:
2026-01-16 13:40:29 +01:00
parent 51cfae7572
commit 35813c8e43
8 changed files with 53 additions and 22 deletions

View File

@@ -6,10 +6,19 @@ meta {
post {
url: {{baseurl}}/sim/activate
body: none
body: formUrlEncoded
auth: inherit
}
params:query {
:
}
body:form-urlencoded {
iccid: 1234
:
}
settings {
encodeUrl: true
timeout: 0

16
docs/sim-api/Health.bru Normal file
View File

@@ -0,0 +1,16 @@
meta {
name: Health
type: http
seq: 5
}
get {
url: {{baseurl}}/health
body: none
auth: inherit
}
settings {
encodeUrl: true
timeout: 0
}

View File

@@ -1,3 +1,3 @@
vars {
baseurl: http://locahost
baseurl: http://localhost:3000
}

View File

@@ -1,6 +1,15 @@
import { DomainEvent } from "./DomainEvent";
export namespace SimEvents {
export type general = DomainEvent & {
key: string,
payload: {
iccid: string
},
options: {
}
}
export type activation = DomainEvent & {
key: "sim.activation",
payload: {

View File

@@ -1,9 +0,0 @@
import { RabbitMQEventBus } from "./RabbitMQEventBus";
export class RabbitMQConsumer {
constructor(
connection: RabbitMQEventBus
) {
}
}

View File

@@ -26,10 +26,10 @@ export async function startRMQClient() {
// Bindings especificos, deberia meterlos en la clase
try {
rabbitmqEventBus.channel?.assertQueue("sim.nos")
await rabbitmqEventBus.channel?.assertQueue("sim.nos")
} catch {
console.log("[i] Cola de sims de nos creada")
rabbitmqEventBus.channel?.bindQueue("sim.nos", "sim.exchange", "sim.nos.*")
await rabbitmqEventBus.channel?.bindQueue("sim.nos", "sim.exchange", "sim.nos.*")
}
return rabbitmqEventBus

View File

@@ -8,6 +8,8 @@ export class SimController {
simUseCases: SimUsecases
}) {
this.simUseCases = args.simUseCases
this.activation = this.activation.bind(this)
}
async activation(req: Request, res: Response) {
@@ -16,22 +18,23 @@ export class SimController {
if (valido == false) return; // Si no es valido ya se ha enviado el error
const { iccid } = req.body
const compañia = "nos" // esto deberia ser un servcio
try {
await this.simUseCases.activation({ iccid })
await this.simUseCases.activation({ iccid, compañia })
} catch (err) {
console.error("Error activando la sim ", req.body)
res.status(500).json({
errors: {
msg: "Error general de activation"
}
})
}).send()
}
res.status(200).json({
iccid: iccid,
operation: "activation"
})
}).send()
}
async cancelation(req: Request, res: Response) {
@@ -148,9 +151,11 @@ export class SimController {
valid = false
}
res.json({
errors: errors
})
if (valid == false) {
res.json({
errors: errors
})
}
return valid;
}

View File

@@ -34,14 +34,15 @@ export class SimUsecases {
return this.eventBus.publish([activationEvent])
}
async activation(args: { iccid: string }) {
const activationEvent = <SimEvents.activation>{
key: "sim.activation",
async activation(args: { iccid: string, compañia: string }) {
const activationEvent = <SimEvents.general>{
key: "sim.nos.activate",
payload: {
iccid: args.iccid
}
}
console.log("publicando", activationEvent)
return this.eventBus.publish([activationEvent])
}