@uns-kit/api 2.0.6 → 2.0.8
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 +6 -3
- package/dist/uns-api-proxy.js +8 -5
- package/package.json +2 -2
package/dist/app.js
CHANGED
|
@@ -45,9 +45,12 @@ export default class App {
|
|
|
45
45
|
this.instanceName = instanceName;
|
|
46
46
|
this.apiBasePrefix =
|
|
47
47
|
normalizeBasePrefix(mountConfig?.apiBasePrefix ?? process.env.UNS_API_BASE_PATH) || "/api";
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
const rawSwaggerBase = normalizeBasePrefix(mountConfig?.swaggerBasePrefix ?? process.env.UNS_SWAGGER_BASE_PATH) ||
|
|
49
|
+
this.apiBasePrefix;
|
|
50
|
+
// If someone passed ".../api" as swagger base, strip that to avoid duplicated segments
|
|
51
|
+
this.swaggerBasePrefix = rawSwaggerBase.endsWith("/api")
|
|
52
|
+
? rawSwaggerBase.replace(/\/api\/?$/, "") || "/"
|
|
53
|
+
: rawSwaggerBase;
|
|
51
54
|
// Add context
|
|
52
55
|
this.expressApplication.use((req, _res, next) => {
|
|
53
56
|
req.appContext = appContext;
|
package/dist/uns-api-proxy.js
CHANGED
|
@@ -49,8 +49,10 @@ export default class UnsApiProxy extends UnsProxy {
|
|
|
49
49
|
this.options = options;
|
|
50
50
|
this.apiBasePrefix =
|
|
51
51
|
normalizeBasePrefix(options.apiBasePath ?? process.env.UNS_API_BASE_PATH) || "/api";
|
|
52
|
-
this.
|
|
53
|
-
|
|
52
|
+
const rawSwaggerBase = normalizeBasePrefix(options.swaggerBasePath ?? process.env.UNS_SWAGGER_BASE_PATH) || this.apiBasePrefix;
|
|
53
|
+
this.swaggerBasePrefix = rawSwaggerBase.endsWith("/api")
|
|
54
|
+
? rawSwaggerBase.replace(/\/api\/?$/, "") || "/"
|
|
55
|
+
: rawSwaggerBase;
|
|
54
56
|
this.app = new App(0, processName, instanceName, undefined, {
|
|
55
57
|
apiBasePrefix: this.apiBasePrefix,
|
|
56
58
|
swaggerBasePrefix: this.swaggerBasePrefix,
|
|
@@ -380,8 +382,8 @@ export default class UnsApiProxy extends UnsProxy {
|
|
|
380
382
|
});
|
|
381
383
|
}
|
|
382
384
|
registerHealthEndpoint() {
|
|
383
|
-
const
|
|
384
|
-
this.app.router.get(
|
|
385
|
+
const routePath = "/status";
|
|
386
|
+
this.app.router.get(routePath, (_req, res) => {
|
|
385
387
|
res.json({
|
|
386
388
|
alive: true,
|
|
387
389
|
processName: this.processName,
|
|
@@ -395,7 +397,8 @@ export default class UnsApiProxy extends UnsProxy {
|
|
|
395
397
|
});
|
|
396
398
|
if (this.app.swaggerSpec) {
|
|
397
399
|
this.app.swaggerSpec.paths = this.app.swaggerSpec.paths || {};
|
|
398
|
-
this.
|
|
400
|
+
const swaggerPath = `${this.apiBasePrefix}${routePath}`.replace(/\/{2,}/g, "/");
|
|
401
|
+
this.app.swaggerSpec.paths[swaggerPath] = {
|
|
399
402
|
get: {
|
|
400
403
|
summary: "Health status",
|
|
401
404
|
responses: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uns-kit/api",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
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.
|
|
38
|
+
"@uns-kit/core": "2.0.8"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/jsonwebtoken": "^9.0.10",
|