Trazabilidad de nos, arreglo de orders
This commit is contained in:
@@ -11,7 +11,7 @@ post {
|
||||
}
|
||||
|
||||
body:form-urlencoded {
|
||||
iccid: 8933201125065160380
|
||||
iccid: 8935103196306448300
|
||||
offer: SAVEFAMILY1
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
],
|
||||
"scripts": {
|
||||
"test": "vitest watch",
|
||||
"build": "yarn workspaces foreach -A --exclude sim-consumidor-nos run build && cp .env dist/ && yarn setup:runtime",
|
||||
"build": "yarn workspaces foreach -A run build && cp .env dist/ && yarn setup:runtime",
|
||||
"setup:runtime": "mkdir -p dist/packages/node_modules && ln -sf ../sim-shared dist/packages/node_modules/sim-shared && ln -sf ../sf-consumidor-objenious dist/packages/node_modules/sim-consumidor-objenious",
|
||||
"start": "yarn setup:runtime && yarn workspaces foreach -Apiv --exclude sim-consumidor-nos run start",
|
||||
"start": "yarn setup:runtime && yarn workspaces foreach -Apiv run start",
|
||||
"typecheck": "npx tsc --noEmit",
|
||||
"dev": "yarn workspaces foreach -Apiv --exclude sim-consumidor-nos run dev ",
|
||||
"dev": "yarn workspaces foreach -Apiv run dev ",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint --fix .",
|
||||
"format": "prettier --write .",
|
||||
|
||||
@@ -132,7 +132,7 @@ export class SimNosController {
|
||||
console.log("ICCID", iccid)
|
||||
|
||||
if (Array.isArray(iccid)) {
|
||||
const usecaseRes = this.uscases.selectMany({ iccid })
|
||||
//const usecaseRes = this.uscases.selectMany({ iccid })
|
||||
} else {
|
||||
const usecaseRes = await this.uscases.selectOne({ iccid })
|
||||
console.log(usecaseRes)
|
||||
|
||||
@@ -83,9 +83,9 @@ export class SimNosUsecases {
|
||||
|
||||
} catch (e) {
|
||||
if (correlation_id != undefined)
|
||||
this.setFailed(correlation_id, "Error general de operacion de SIM (NOS)", String(e)).then()
|
||||
this.setFailed(correlation_id, "Error general de operacion de SIM (NOS) ", String(e)).then()
|
||||
return {
|
||||
error: "Error general de operacion de SIM (NOS)" + String(e)
|
||||
error: "Error general de operacion de SIM (NOS) " + String(e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
18
packages/sim-consumidor-nos/config/postgreConfig.ts
Normal file
18
packages/sim-consumidor-nos/config/postgreConfig.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Pool, QueryResult } from 'pg';
|
||||
import { PgClient } from 'sim-shared/infrastructure/PgClient.js'
|
||||
import { env } from './env/env.js';
|
||||
|
||||
// Configuracion de la conexion a la BDD, deberia ser la
|
||||
// Misma para todos los servicios pero hasta que se unifique todo
|
||||
// se hace una por servicio.
|
||||
export const pgPool = new Pool({
|
||||
user: env.POSTGRES_USER,
|
||||
host: env.POSTGRES_HOST,
|
||||
database: env.POSTGRES_DATABASE,
|
||||
password: env.POSTGRES_PASSWORD,
|
||||
port: Number(env.POSTGRES_PORT) || 5433,
|
||||
});
|
||||
|
||||
export const pgClient = new PgClient({
|
||||
pool: pgPool
|
||||
})
|
||||
@@ -1,12 +1,14 @@
|
||||
import express from "express"
|
||||
import cors from 'cors';
|
||||
import { startRMQClient } from "#config/eventBus.config.js"
|
||||
import { SimNosRouter } from "aplication/SimNOS.router.js"
|
||||
import { SimNosRouter } from "./aplication/SimNOS.router.js"
|
||||
import { SimNosController } from "./aplication/SimNOS.controller.js"
|
||||
import { SimNosUsecases } from "aplication/SimNOS.usecases.js"
|
||||
import { NosHttpClient } from "infrastructure/NosHttpClient.js"
|
||||
import { SimNosUsecases } from "./aplication/SimNOS.usecases.js"
|
||||
import { NosHttpClient } from "./infrastructure/NosHttpClient.js"
|
||||
import { env } from "#config/env/env.js"
|
||||
import { NosRepository } from "infrastructure/NosRepository.js"
|
||||
import { NosRepository } from "./infrastructure/NosRepository.js"
|
||||
import { OrderRepository } from "sim-shared/infrastructure/OrderRepository.js";
|
||||
import { pgClient } from "#config/postgreConfig.js";
|
||||
|
||||
const RMQ_QUEUE = "sim.nos"
|
||||
const NOS_BASE_URL = env.NOS_BASE_URL
|
||||
@@ -25,9 +27,14 @@ async function startWorker() {
|
||||
nosHttpClient
|
||||
)
|
||||
|
||||
const orderRepository = new OrderRepository(
|
||||
pgClient
|
||||
)
|
||||
|
||||
const simUsecases = new SimNosUsecases(
|
||||
nosHttpClient,
|
||||
nosRepository
|
||||
nosRepository,
|
||||
orderRepository
|
||||
)
|
||||
|
||||
const simController = new SimNosController(
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
"@types/supertest": "*",
|
||||
"prettier": "*",
|
||||
"supertest": "*",
|
||||
"tsc-alias": "^1.8.16",
|
||||
"tsx": "*",
|
||||
"vitest": "*"
|
||||
}
|
||||
|
||||
5
packages/sim-consumidor-nos/test.env
Normal file
5
packages/sim-consumidor-nos/test.env
Normal file
@@ -0,0 +1,5 @@
|
||||
## ENV PARA DATOS DE TEST - shared nunca se lanza en produccion
|
||||
|
||||
NOTIFICATION_URL="https://sf-sim-activation.savefamilygps.net/send-activation-mail"
|
||||
# NOTIFICATION_URL="localhost"
|
||||
SIM_ACTIVATION_API_KEY=9e48c4ac-1ab0-4397-b3f3-6c239200dfe6
|
||||
@@ -124,3 +124,5 @@ export class PauseCancelTaskRepository {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default PauseCancelTask
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { rabbitmqEventBus } from '#config/eventBusConfig.js';
|
||||
import { rabbitmqEventBus } from '../config/eventBusConfig.js';
|
||||
import { SimUsecases } from '../aplication/Sim.usecases.js';
|
||||
import { SimController } from '../aplication/Sim.controller.js';
|
||||
import { Router } from 'express';
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
],
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
"**/*.d.ts",
|
||||
"../../packages/sim-shared/**/*.ts",
|
||||
"../../packages/sim-consumidor-objenious/**/*.ts"
|
||||
]
|
||||
|
||||
@@ -380,6 +380,7 @@ export class OrderRepository {
|
||||
|
||||
const id = currentOrderResult.data.id // Saco el id para evitar busacr por correlation_id que es mas lento
|
||||
const currentOrder = currentOrderResult.data!
|
||||
console.log("Current Order", currentOrder)
|
||||
|
||||
// 3. Si todo ok se actualiza el order
|
||||
// Si el status es dlx se asume que ha terminado y no va a reintentarse
|
||||
@@ -423,7 +424,7 @@ export class OrderRepository {
|
||||
)
|
||||
RETURNING id;
|
||||
`
|
||||
const vOrderHistory = [args.id, currentOrder.status, args.status, args.reason]
|
||||
const vOrderHistory = [currentOrder.id, currentOrder.status, args.status, args.reason]
|
||||
const newOrderHistoryResult = await this.getFirst(
|
||||
client.query<{ id: number }>(iOrderHistory, vOrderHistory)
|
||||
)
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
"resolveJsonModule": true,
|
||||
"module": "nodenext",
|
||||
"moduleResolution": "nodenext",
|
||||
"paths": {
|
||||
"sim-consumidor-objenious": [
|
||||
"./packages/sim-consumidor-objenious/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
@@ -20,5 +25,5 @@
|
||||
],
|
||||
"exclude": [
|
||||
"dist"
|
||||
]
|
||||
],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user