@forklaunch/hyper-express 0.11.9 → 0.11.11
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/lib/index.js +40 -28
- package/lib/index.mjs +40 -28
- package/package.json +9 -9
package/lib/index.js
CHANGED
|
@@ -40,72 +40,74 @@ var import_http15 = require("@forklaunch/core/http");
|
|
|
40
40
|
|
|
41
41
|
// src/handlers/any.ts
|
|
42
42
|
var import_http = require("@forklaunch/core/http");
|
|
43
|
-
var any = (schemaValidator,
|
|
44
|
-
return (0, import_http.middleware)(schemaValidator,
|
|
43
|
+
var any = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
44
|
+
return (0, import_http.middleware)(schemaValidator, path2, contractDetails, ...handlers2);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
// src/handlers/delete.ts
|
|
48
48
|
var import_http2 = require("@forklaunch/core/http");
|
|
49
|
-
var delete_ = (schemaValidator,
|
|
50
|
-
return (0, import_http2.delete_)(schemaValidator,
|
|
49
|
+
var delete_ = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
50
|
+
return (0, import_http2.delete_)(schemaValidator, path2, contractDetails, ...handlers2);
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
// src/handlers/get.ts
|
|
54
54
|
var import_http3 = require("@forklaunch/core/http");
|
|
55
|
-
var get = (schemaValidator,
|
|
56
|
-
return (0, import_http3.get)(schemaValidator,
|
|
55
|
+
var get = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
56
|
+
return (0, import_http3.get)(schemaValidator, path2, contractDetails, ...handlers2);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
// src/handlers/head.ts
|
|
60
60
|
var import_http4 = require("@forklaunch/core/http");
|
|
61
|
-
var head = (schemaValidator,
|
|
62
|
-
return (0, import_http4.head)(schemaValidator,
|
|
61
|
+
var head = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
62
|
+
return (0, import_http4.head)(schemaValidator, path2, contractDetails, ...handlers2);
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
// src/handlers/middleware.ts
|
|
66
66
|
var import_http5 = require("@forklaunch/core/http");
|
|
67
|
-
var middleware2 = (schemaValidator,
|
|
68
|
-
return (0, import_http5.middleware)(schemaValidator,
|
|
67
|
+
var middleware2 = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
68
|
+
return (0, import_http5.middleware)(schemaValidator, path2, contractDetails, ...handlers2);
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
// src/handlers/options.ts
|
|
72
72
|
var import_http6 = require("@forklaunch/core/http");
|
|
73
|
-
var options = (schemaValidator,
|
|
74
|
-
return (0, import_http6.options)(schemaValidator,
|
|
73
|
+
var options = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
74
|
+
return (0, import_http6.options)(schemaValidator, path2, contractDetails, ...handlers2);
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
// src/handlers/patch.ts
|
|
78
78
|
var import_http7 = require("@forklaunch/core/http");
|
|
79
|
-
var patch = (schemaValidator,
|
|
80
|
-
return (0, import_http7.patch)(schemaValidator,
|
|
79
|
+
var patch = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
80
|
+
return (0, import_http7.patch)(schemaValidator, path2, contractDetails, ...handlers2);
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
// src/handlers/post.ts
|
|
84
84
|
var import_http8 = require("@forklaunch/core/http");
|
|
85
|
-
var post = (schemaValidator,
|
|
86
|
-
return (0, import_http8.post)(schemaValidator,
|
|
85
|
+
var post = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
86
|
+
return (0, import_http8.post)(schemaValidator, path2, contractDetails, ...handlers2);
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
// src/handlers/put.ts
|
|
90
90
|
var import_http9 = require("@forklaunch/core/http");
|
|
91
|
-
var put = (schemaValidator,
|
|
92
|
-
return (0, import_http9.put)(schemaValidator,
|
|
91
|
+
var put = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
92
|
+
return (0, import_http9.put)(schemaValidator, path2, contractDetails, ...handlers2);
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
// src/handlers/trace.ts
|
|
96
96
|
var import_http10 = require("@forklaunch/core/http");
|
|
97
|
-
var trace = (schemaValidator,
|
|
98
|
-
return (0, import_http10.trace)(schemaValidator,
|
|
97
|
+
var trace = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
98
|
+
return (0, import_http10.trace)(schemaValidator, path2, contractDetails, ...handlers2);
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
// src/hyperExpressApplication.ts
|
|
102
102
|
var import_common3 = require("@forklaunch/common");
|
|
103
103
|
var import_http13 = require("@forklaunch/core/http");
|
|
104
|
+
var import_environment = require("@forklaunch/core/environment");
|
|
104
105
|
var import_hyper_express_fork = require("@forklaunch/hyper-express-fork");
|
|
105
106
|
var import_zod = require("@forklaunch/validator/zod");
|
|
106
107
|
var import_express_api_reference = require("@scalar/express-api-reference");
|
|
107
108
|
var import_crypto = __toESM(require("crypto"));
|
|
108
109
|
var import_fs = __toESM(require("fs"));
|
|
110
|
+
var import_path = __toESM(require("path"));
|
|
109
111
|
|
|
110
112
|
// src/cluster/hyperExpress.cluster.ts
|
|
111
113
|
var import_node_cluster = __toESM(require("cluster"));
|
|
@@ -372,15 +374,15 @@ function enrichResponseTransmission(req, res, next) {
|
|
|
372
374
|
var import_live_directory = __toESM(require("live-directory"));
|
|
373
375
|
var import_absolute_path = __toESM(require("swagger-ui-dist/absolute-path"));
|
|
374
376
|
var import_swagger_ui_express = __toESM(require("swagger-ui-express"));
|
|
375
|
-
function swaggerRedirect(
|
|
377
|
+
function swaggerRedirect(path2) {
|
|
376
378
|
return function swaggerHosting(req, res, next) {
|
|
377
|
-
if (req.path ===
|
|
378
|
-
res.redirect(`${
|
|
379
|
+
if (req.path === path2) {
|
|
380
|
+
res.redirect(`${path2}/`);
|
|
379
381
|
}
|
|
380
382
|
return next?.();
|
|
381
383
|
};
|
|
382
384
|
}
|
|
383
|
-
function swagger(
|
|
385
|
+
function swagger(path2, document, opts, options2, customCss, customfavIcon, swaggerUrl, customSiteTitle) {
|
|
384
386
|
const LiveAssets = new import_live_directory.default((0, import_absolute_path.default)(), {
|
|
385
387
|
filter: {
|
|
386
388
|
keep: {
|
|
@@ -401,7 +403,7 @@ function swagger(path, document, opts, options2, customCss, customfavIcon, swagg
|
|
|
401
403
|
});
|
|
402
404
|
const serve = import_swagger_ui_express.default.serve[0];
|
|
403
405
|
const staticAssets = (req, res, next) => {
|
|
404
|
-
const filePath = req.path.replace(
|
|
406
|
+
const filePath = req.path.replace(path2, "");
|
|
405
407
|
const file = LiveAssets.get(filePath);
|
|
406
408
|
if (file === void 0) {
|
|
407
409
|
if (next) {
|
|
@@ -477,8 +479,18 @@ var Application = class extends import_http13.ForklaunchExpressLikeApplication {
|
|
|
477
479
|
this,
|
|
478
480
|
this.openapiConfiguration
|
|
479
481
|
);
|
|
482
|
+
const serviceName = process.env.OTEL_SERVICE_NAME || "unknown-service";
|
|
483
|
+
const appRoot = (0, import_environment.findApplicationRoot)(process.cwd());
|
|
484
|
+
const outputPath = process.env.FORKLAUNCH_OPENAPI_OUTPUT || import_path.default.join(
|
|
485
|
+
appRoot,
|
|
486
|
+
".forklaunch",
|
|
487
|
+
"openapi",
|
|
488
|
+
serviceName,
|
|
489
|
+
"openapi.json"
|
|
490
|
+
);
|
|
491
|
+
import_fs.default.mkdirSync(import_path.default.dirname(outputPath), { recursive: true });
|
|
480
492
|
import_fs.default.writeFileSync(
|
|
481
|
-
|
|
493
|
+
outputPath,
|
|
482
494
|
JSON.stringify(
|
|
483
495
|
{
|
|
484
496
|
...openApiSpec,
|
|
@@ -711,8 +723,8 @@ var Router = class _Router extends import_http14.ForklaunchExpressLikeRouter {
|
|
|
711
723
|
this.internal.use(polyfillGetHeaders);
|
|
712
724
|
}
|
|
713
725
|
configOptions;
|
|
714
|
-
route(
|
|
715
|
-
this.internal.route(
|
|
726
|
+
route(path2) {
|
|
727
|
+
this.internal.route(path2);
|
|
716
728
|
return this;
|
|
717
729
|
}
|
|
718
730
|
any = (pathOrContractDetailsOrMiddlewareOrTypedHandler, contractDetailsOrMiddlewareOrTypedHandler, ...middlewareOrMiddlewareWithTypedHandler) => {
|
package/lib/index.mjs
CHANGED
|
@@ -7,80 +7,80 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
middleware
|
|
9
9
|
} from "@forklaunch/core/http";
|
|
10
|
-
var any = (schemaValidator,
|
|
11
|
-
return middleware(schemaValidator,
|
|
10
|
+
var any = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
11
|
+
return middleware(schemaValidator, path2, contractDetails, ...handlers2);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
// src/handlers/delete.ts
|
|
15
15
|
import {
|
|
16
16
|
delete_ as innerDelete
|
|
17
17
|
} from "@forklaunch/core/http";
|
|
18
|
-
var delete_ = (schemaValidator,
|
|
19
|
-
return innerDelete(schemaValidator,
|
|
18
|
+
var delete_ = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
19
|
+
return innerDelete(schemaValidator, path2, contractDetails, ...handlers2);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
// src/handlers/get.ts
|
|
23
23
|
import {
|
|
24
24
|
get as innerGet
|
|
25
25
|
} from "@forklaunch/core/http";
|
|
26
|
-
var get = (schemaValidator,
|
|
27
|
-
return innerGet(schemaValidator,
|
|
26
|
+
var get = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
27
|
+
return innerGet(schemaValidator, path2, contractDetails, ...handlers2);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
// src/handlers/head.ts
|
|
31
31
|
import {
|
|
32
32
|
head as innerHead
|
|
33
33
|
} from "@forklaunch/core/http";
|
|
34
|
-
var head = (schemaValidator,
|
|
35
|
-
return innerHead(schemaValidator,
|
|
34
|
+
var head = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
35
|
+
return innerHead(schemaValidator, path2, contractDetails, ...handlers2);
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
// src/handlers/middleware.ts
|
|
39
39
|
import {
|
|
40
40
|
middleware as innerMiddleware
|
|
41
41
|
} from "@forklaunch/core/http";
|
|
42
|
-
var middleware2 = (schemaValidator,
|
|
43
|
-
return innerMiddleware(schemaValidator,
|
|
42
|
+
var middleware2 = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
43
|
+
return innerMiddleware(schemaValidator, path2, contractDetails, ...handlers2);
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
// src/handlers/options.ts
|
|
47
47
|
import {
|
|
48
48
|
options as innerOptions
|
|
49
49
|
} from "@forklaunch/core/http";
|
|
50
|
-
var options = (schemaValidator,
|
|
51
|
-
return innerOptions(schemaValidator,
|
|
50
|
+
var options = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
51
|
+
return innerOptions(schemaValidator, path2, contractDetails, ...handlers2);
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
// src/handlers/patch.ts
|
|
55
55
|
import {
|
|
56
56
|
patch as innerPatch
|
|
57
57
|
} from "@forklaunch/core/http";
|
|
58
|
-
var patch = (schemaValidator,
|
|
59
|
-
return innerPatch(schemaValidator,
|
|
58
|
+
var patch = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
59
|
+
return innerPatch(schemaValidator, path2, contractDetails, ...handlers2);
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
// src/handlers/post.ts
|
|
63
63
|
import {
|
|
64
64
|
post as innerPost
|
|
65
65
|
} from "@forklaunch/core/http";
|
|
66
|
-
var post = (schemaValidator,
|
|
67
|
-
return innerPost(schemaValidator,
|
|
66
|
+
var post = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
67
|
+
return innerPost(schemaValidator, path2, contractDetails, ...handlers2);
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
// src/handlers/put.ts
|
|
71
71
|
import {
|
|
72
72
|
put as innerPut
|
|
73
73
|
} from "@forklaunch/core/http";
|
|
74
|
-
var put = (schemaValidator,
|
|
75
|
-
return innerPut(schemaValidator,
|
|
74
|
+
var put = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
75
|
+
return innerPut(schemaValidator, path2, contractDetails, ...handlers2);
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
// src/handlers/trace.ts
|
|
79
79
|
import {
|
|
80
80
|
trace as innerTrace
|
|
81
81
|
} from "@forklaunch/core/http";
|
|
82
|
-
var trace = (schemaValidator,
|
|
83
|
-
return innerTrace(schemaValidator,
|
|
82
|
+
var trace = (schemaValidator, path2, contractDetails, ...handlers2) => {
|
|
83
|
+
return innerTrace(schemaValidator, path2, contractDetails, ...handlers2);
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
// src/hyperExpressApplication.ts
|
|
@@ -94,6 +94,7 @@ import {
|
|
|
94
94
|
isPortBound,
|
|
95
95
|
OPENAPI_DEFAULT_VERSION
|
|
96
96
|
} from "@forklaunch/core/http";
|
|
97
|
+
import { findApplicationRoot } from "@forklaunch/core/environment";
|
|
97
98
|
import {
|
|
98
99
|
Server
|
|
99
100
|
} from "@forklaunch/hyper-express-fork";
|
|
@@ -101,6 +102,7 @@ import { ZodSchemaValidator } from "@forklaunch/validator/zod";
|
|
|
101
102
|
import { apiReference } from "@scalar/express-api-reference";
|
|
102
103
|
import crypto from "crypto";
|
|
103
104
|
import fs from "fs";
|
|
105
|
+
import path from "path";
|
|
104
106
|
|
|
105
107
|
// src/cluster/hyperExpress.cluster.ts
|
|
106
108
|
import cluster from "cluster";
|
|
@@ -369,15 +371,15 @@ function enrichResponseTransmission(req, res, next) {
|
|
|
369
371
|
import LiveDirectory from "live-directory";
|
|
370
372
|
import getAbsoluteSwaggerFsPath from "swagger-ui-dist/absolute-path";
|
|
371
373
|
import swaggerUi from "swagger-ui-express";
|
|
372
|
-
function swaggerRedirect(
|
|
374
|
+
function swaggerRedirect(path2) {
|
|
373
375
|
return function swaggerHosting(req, res, next) {
|
|
374
|
-
if (req.path ===
|
|
375
|
-
res.redirect(`${
|
|
376
|
+
if (req.path === path2) {
|
|
377
|
+
res.redirect(`${path2}/`);
|
|
376
378
|
}
|
|
377
379
|
return next?.();
|
|
378
380
|
};
|
|
379
381
|
}
|
|
380
|
-
function swagger(
|
|
382
|
+
function swagger(path2, document, opts, options2, customCss, customfavIcon, swaggerUrl, customSiteTitle) {
|
|
381
383
|
const LiveAssets = new LiveDirectory(getAbsoluteSwaggerFsPath(), {
|
|
382
384
|
filter: {
|
|
383
385
|
keep: {
|
|
@@ -398,7 +400,7 @@ function swagger(path, document, opts, options2, customCss, customfavIcon, swagg
|
|
|
398
400
|
});
|
|
399
401
|
const serve = swaggerUi.serve[0];
|
|
400
402
|
const staticAssets = (req, res, next) => {
|
|
401
|
-
const filePath = req.path.replace(
|
|
403
|
+
const filePath = req.path.replace(path2, "");
|
|
402
404
|
const file = LiveAssets.get(filePath);
|
|
403
405
|
if (file === void 0) {
|
|
404
406
|
if (next) {
|
|
@@ -474,8 +476,18 @@ var Application = class extends ForklaunchExpressLikeApplication {
|
|
|
474
476
|
this,
|
|
475
477
|
this.openapiConfiguration
|
|
476
478
|
);
|
|
479
|
+
const serviceName = process.env.OTEL_SERVICE_NAME || "unknown-service";
|
|
480
|
+
const appRoot = findApplicationRoot(process.cwd());
|
|
481
|
+
const outputPath = process.env.FORKLAUNCH_OPENAPI_OUTPUT || path.join(
|
|
482
|
+
appRoot,
|
|
483
|
+
".forklaunch",
|
|
484
|
+
"openapi",
|
|
485
|
+
serviceName,
|
|
486
|
+
"openapi.json"
|
|
487
|
+
);
|
|
488
|
+
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
477
489
|
fs.writeFileSync(
|
|
478
|
-
|
|
490
|
+
outputPath,
|
|
479
491
|
JSON.stringify(
|
|
480
492
|
{
|
|
481
493
|
...openApiSpec,
|
|
@@ -712,8 +724,8 @@ var Router = class _Router extends ForklaunchExpressLikeRouter {
|
|
|
712
724
|
this.internal.use(polyfillGetHeaders);
|
|
713
725
|
}
|
|
714
726
|
configOptions;
|
|
715
|
-
route(
|
|
716
|
-
this.internal.route(
|
|
727
|
+
route(path2) {
|
|
728
|
+
this.internal.route(path2);
|
|
717
729
|
return this;
|
|
718
730
|
}
|
|
719
731
|
any = (pathOrContractDetailsOrMiddlewareOrTypedHandler, contractDetailsOrMiddlewareOrTypedHandler, ...middlewareOrMiddlewareWithTypedHandler) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/hyper-express",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.11",
|
|
4
4
|
"description": "Forklaunch framework for hyper-express.",
|
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@forklaunch/hyper-express-fork": "^6.17.35",
|
|
29
|
-
"@scalar/express-api-reference": "^0.9.
|
|
29
|
+
"@scalar/express-api-reference": "^0.9.2",
|
|
30
30
|
"cors": "^2.8.6",
|
|
31
31
|
"live-directory": "^3.0.3",
|
|
32
32
|
"openapi3-ts": "^4.5.0",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"swagger-ui-dist": "^5.32.0",
|
|
35
35
|
"swagger-ui-express": "^5.0.1",
|
|
36
36
|
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.52.0",
|
|
37
|
-
"@forklaunch/common": "0.6.
|
|
38
|
-
"@forklaunch/
|
|
39
|
-
"@forklaunch/
|
|
40
|
-
"@forklaunch/validator": "0.10.
|
|
37
|
+
"@forklaunch/common": "0.6.34",
|
|
38
|
+
"@forklaunch/core": "0.18.7",
|
|
39
|
+
"@forklaunch/ws": "0.2.5",
|
|
40
|
+
"@forklaunch/validator": "0.10.34"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@eslint/js": "^10.0.1",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"@types/qs": "^6.15.0",
|
|
48
48
|
"@types/swagger-ui-dist": "^3.30.6",
|
|
49
49
|
"@types/swagger-ui-express": "^4.1.8",
|
|
50
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
51
|
-
"jest": "^30.
|
|
50
|
+
"@typescript/native-preview": "7.0.0-dev.20260311.1",
|
|
51
|
+
"jest": "^30.3.0",
|
|
52
52
|
"kill-port-process": "^4.0.2",
|
|
53
53
|
"prettier": "^3.8.1",
|
|
54
54
|
"ts-jest": "^29.4.6",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"tsx": "^4.21.0",
|
|
58
58
|
"typedoc": "^0.28.17",
|
|
59
59
|
"typescript": "^5.9.3",
|
|
60
|
-
"typescript-eslint": "^8.
|
|
60
|
+
"typescript-eslint": "^8.57.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsgo --noEmit && tsup index.ts --format cjs,esm --no-splitting --dts --tsconfig tsconfig.json --out-dir lib --clean",
|