@oas-tools/oas-telemetry 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -46,7 +46,7 @@ function oasTelemetry(OasTlmConfig) {
46
46
  }
47
47
  }
48
48
  console.log("baseURL: ", _config.globalOasTlmConfig.baseURL);
49
- _config.globalOasTlmConfig.dynamicExporter.changeExporter(OasTlmConfig.exporter ?? new _InMemoryDbExporter.InMemoryExporter());
49
+ _config.globalOasTlmConfig.dynamicExporter.changeExporter(_config.globalOasTlmConfig.exporter ?? new _InMemoryDbExporter.InMemoryExporter());
50
50
  if (_config.globalOasTlmConfig.spec) dbglog(`Spec content provided`);else {
51
51
  if (_config.globalOasTlmConfig.specFileName != "") dbglog(`Spec file used for telemetry: ${_config.globalOasTlmConfig.specFileName}`);else {
52
52
  console.error("No spec available !");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oas-tools/oas-telemetry",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "This package exports an Express middleware that traces requests and responses of an Express application using OpenTelemetry.",
5
5
  "author": "Manuel Otero",
6
6
  "contributors": [
package/src/index.js CHANGED
@@ -31,8 +31,16 @@ if (process.env.OTDEBUG == "true")
31
31
  */
32
32
  export default function oasTelemetry(OasTlmConfig) {
33
33
  const router = Router();
34
+ router.use((req, res, next) => {
35
+ if (req.body !== undefined) {
36
+ return next(); // Ya parseado, evitar json()
37
+ }
38
+
39
+ return json()(req, res, next);
40
+ });
41
+
34
42
  if (process.env.OASTLM_MODULE_DISABLED === 'true') {
35
- return router;
43
+ return router;
36
44
  };
37
45
  if (OasTlmConfig) {
38
46
  console.log("User provided config");
@@ -42,7 +50,7 @@ export default function oasTelemetry(OasTlmConfig) {
42
50
  }
43
51
  }
44
52
  console.log("baseURL: ", globalOasTlmConfig.baseURL);
45
- globalOasTlmConfig.dynamicExporter.changeExporter( OasTlmConfig.exporter ?? new InMemoryExporter() );
53
+ globalOasTlmConfig.dynamicExporter.changeExporter(globalOasTlmConfig.exporter ?? new InMemoryExporter());
46
54
 
47
55
  if (globalOasTlmConfig.spec)
48
56
  dbglog(`Spec content provided`);
@@ -53,9 +61,8 @@ export default function oasTelemetry(OasTlmConfig) {
53
61
  console.error("No spec available !");
54
62
  }
55
63
  }
56
- let allAuthMiddlewares = getWrappedMiddlewares(() => globalOasTlmConfig.authEnabled, [cookieParser(),authRoutes,authMiddleware]);
64
+ let allAuthMiddlewares = getWrappedMiddlewares(() => globalOasTlmConfig.authEnabled, [cookieParser(), authRoutes, authMiddleware]);
57
65
  const baseURL = globalOasTlmConfig.baseURL;
58
- router.use(json());
59
66
  router.use(baseURL, allAuthMiddlewares);
60
67
  router.use(baseURL, telemetryRoutes);
61
68
  router.use(baseURL + "/metrics", metricsRoutes);