Pruebas a los endpoints internos
This commit is contained in:
@@ -7,6 +7,7 @@ import { env } from "#config/env/index.js"
|
|||||||
import { orderRoutes } from "#adapters/orderRoutes.http.js";
|
import { orderRoutes } from "#adapters/orderRoutes.http.js";
|
||||||
import { connectionsRoutes } from "#adapters/simconnectionsRoutes.js";
|
import { connectionsRoutes } from "#adapters/simconnectionsRoutes.js";
|
||||||
import { franceRoutes } from "#adapters/franceRoutes.http.js";
|
import { franceRoutes } from "#adapters/franceRoutes.http.js";
|
||||||
|
import { spainRoutes } from "#adapters/spainRoutes.http.js";
|
||||||
|
|
||||||
const PORT = env.API_PORT
|
const PORT = env.API_PORT
|
||||||
const HOSTNAME = "0.0.0.0"
|
const HOSTNAME = "0.0.0.0"
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ franceRoutes.use("", createProxyMiddleware({
|
|||||||
const host = req.get('host');
|
const host = req.get('host');
|
||||||
const originalFullUrl = `${protocol}://${host}${req.originalUrl}`;
|
const originalFullUrl = `${protocol}://${host}${req.originalUrl}`;
|
||||||
const destinationFullUrl = `${FRANCE_URL}${proxyReq.path}`;
|
const destinationFullUrl = `${FRANCE_URL}${proxyReq.path}`;
|
||||||
//console.log(`[Proxy Req]: ${req.method} ${req.url} -> ${proxyReq.path}`);
|
console.log(`[Proxy FR]: ${req.method} ${req.url} -> ${proxyReq.path}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { Router, Request } from "express"
|
||||||
|
import { ClientRequest, } from "http"
|
||||||
|
import { createProxyMiddleware } from "http-proxy-middleware"
|
||||||
|
import { env } from "#config/env/index.js"
|
||||||
|
import assert from "node:assert"
|
||||||
|
|
||||||
|
const portugalRoutes = Router()
|
||||||
|
|
||||||
|
const PORTUGAL_URL = env.NOS_CONSUMER_URL
|
||||||
|
assert.ok(PORTUGAL_URL, "No se ha definido una URL para el servicio consumidor de Francia")
|
||||||
|
|
||||||
|
portugalRoutes.use("", createProxyMiddleware({
|
||||||
|
target: PORTUGAL_URL,
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: {
|
||||||
|
'^/spain/*': '/'
|
||||||
|
},
|
||||||
|
|
||||||
|
on: {
|
||||||
|
proxyReq: (proxyReq: ClientRequest, req: Request) => {
|
||||||
|
/* Debug de las peticiones */
|
||||||
|
const protocol = req.protocol;
|
||||||
|
const host = req.get('host');
|
||||||
|
const originalFullUrl = `${protocol}://${host}${req.originalUrl}`;
|
||||||
|
const destinationFullUrl = `${PORTUGAL_URL}${proxyReq.path}`;
|
||||||
|
console.log(`[Proxy PT]: ${req.method} ${req.url} -> ${proxyReq.path}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
))
|
||||||
|
|
||||||
|
export { portugalRoutes }
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { Router, Request } from "express"
|
||||||
|
import { ClientRequest, } from "http"
|
||||||
|
import { createProxyMiddleware } from "http-proxy-middleware"
|
||||||
|
import { env } from "#config/env/index.js"
|
||||||
|
import assert from "node:assert"
|
||||||
|
|
||||||
|
const spainRoutes = Router()
|
||||||
|
|
||||||
|
const SPAIN_URL = env.ALAI_CONSUMER_URL
|
||||||
|
assert.ok(SPAIN_URL, "No se ha definido una URL para el servicio consumidor de Francia")
|
||||||
|
|
||||||
|
spainRoutes.use("", createProxyMiddleware({
|
||||||
|
target: SPAIN_URL,
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: {
|
||||||
|
'^/spain/*': '/'
|
||||||
|
},
|
||||||
|
|
||||||
|
on: {
|
||||||
|
proxyReq: (proxyReq: ClientRequest, req: Request) => {
|
||||||
|
/* Debug de las peticiones */
|
||||||
|
const protocol = req.protocol;
|
||||||
|
const host = req.get('host');
|
||||||
|
const originalFullUrl = `${protocol}://${host}${req.originalUrl}`;
|
||||||
|
const destinationFullUrl = `${SPAIN_URL}${proxyReq.path}`;
|
||||||
|
console.log(`[Proxy ES]: ${req.method} ${req.url} -> ${proxyReq.path}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
))
|
||||||
|
|
||||||
|
//orderRoutes.get("/:iccid/suspended-time",)
|
||||||
|
export { spainRoutes }
|
||||||
Reference in New Issue
Block a user