@uns-kit/api 2.0.5 → 2.0.6

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/app.js CHANGED
@@ -17,6 +17,14 @@ const normalizeBasePrefix = (value) => {
17
17
  const withLeading = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
18
18
  return withLeading.replace(/\/+$/, "");
19
19
  };
20
+ const buildSwaggerPath = (base, processName, instanceName) => {
21
+ const processSegment = `/${processName}`;
22
+ let baseWithProcess = base || "/";
23
+ if (!baseWithProcess.endsWith(processSegment)) {
24
+ baseWithProcess = `${baseWithProcess}${processSegment}`;
25
+ }
26
+ return `${baseWithProcess}/${instanceName}/swagger.json`.replace(/\/{2,}/g, "/");
27
+ };
20
28
  export default class App {
21
29
  expressApplication;
22
30
  server;
@@ -131,7 +139,7 @@ export default class App {
131
139
  port = "";
132
140
  }
133
141
  logger.info(`API listening on http://${ip}:${port}${this.apiBasePrefix}`);
134
- const swaggerPath = `${this.swaggerBasePrefix}/${this.processName}/${this.instanceName}/swagger.json`.replace(/\/{2,}/g, "/");
142
+ const swaggerPath = buildSwaggerPath(this.swaggerBasePrefix, this.processName, this.instanceName);
135
143
  logger.info(`Swagger openAPI on http://${ip}:${port}${swaggerPath}`);
136
144
  this.expressApplication.get(swaggerPath, (req, res) => res.json(this.getSwaggerSpec()));
137
145
  });
@@ -22,6 +22,14 @@ const normalizeBasePrefix = (value) => {
22
22
  const withLeading = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
23
23
  return withLeading.replace(/\/+$/, "");
24
24
  };
25
+ const buildSwaggerPath = (base, processName, instanceName) => {
26
+ const processSegment = `/${processName}`;
27
+ let baseWithProcess = base || "/";
28
+ if (!baseWithProcess.endsWith(processSegment)) {
29
+ baseWithProcess = `${baseWithProcess}${processSegment}`;
30
+ }
31
+ return `${baseWithProcess}/${instanceName}/swagger.json`.replace(/\/{2,}/g, "/");
32
+ };
25
33
  export default class UnsApiProxy extends UnsProxy {
26
34
  instanceName;
27
35
  topicBuilder;
@@ -109,7 +117,7 @@ export default class UnsApiProxy extends UnsProxy {
109
117
  const time = UnsPacket.formatToISO8601(new Date());
110
118
  const fullPath = `/${topic}${attribute}`;
111
119
  const apiPath = `${this.apiBasePrefix}${fullPath}`.replace(/\/{2,}/g, "/");
112
- const swaggerPath = `${this.swaggerBasePrefix}/${this.processName}/${this.instanceName}/swagger.json`.replace(/\/{2,}/g, "/");
120
+ const swaggerPath = buildSwaggerPath(this.swaggerBasePrefix, this.processName, this.instanceName);
113
121
  try {
114
122
  // Get ip and port from environment variables or defaults
115
123
  const addressInfo = this.app.server.address();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uns-kit/api",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "Express-powered API gateway plugin for UnsProxyProcess with JWT/JWKS support.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "cookie-parser": "^1.4.7",
36
36
  "express": "^5.1.0",
37
37
  "multer": "^2.0.2",
38
- "@uns-kit/core": "2.0.5"
38
+ "@uns-kit/core": "2.0.6"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/jsonwebtoken": "^9.0.10",