@forklaunch/hyper-express 0.10.2 → 0.11.1

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.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _forklaunch_core_http from '@forklaunch/core/http';
2
- import { ParamsObject, ResponsesObject, Body, QueryObject, HeadersObject, VersionSchema, SchemaAuthMethods, ContractDetails, ExpressLikeSchemaHandler, ResolvedSessionObject, SessionObject, ExpressLikeApplicationOptions, ExpressLikeRouterOptions, ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefinition, ParsedQs, StringOnlyObject, MiddlewareContractDetails, PathMatch, TypedHandler, ForklaunchExpressLikeRouter, ForklaunchRouter, TypedMiddlewareDefinition } from '@forklaunch/core/http';
3
- import { AnySchemaValidator, Schema } from '@forklaunch/validator';
2
+ import { ParamsObject, ResponsesObject, Body, QueryObject, HeadersObject, VersionSchema, SchemaAuthMethods, ContractDetails, ExpressLikeSchemaHandler, ResolvedSessionObject, SessionObject, ExpressLikeApplicationOptions, ExpressLikeRouterOptions, ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefinition, ParsedQs, StringOnlyObject, MiddlewareContractDetails, PathMatch, TypedHandler, ForklaunchExpressLikeRouter, ForklaunchRouter, TypedMiddlewareDefinition, Method, ContractDetailsOrMiddlewareOrTypedHandler, MiddlewareOrMiddlewareWithTypedHandler } from '@forklaunch/core/http';
4
3
  import { Request, Response, MiddlewareNext, ServerConstructorOptions, Server, MiddlewareHandler, Router as Router$1, WSRouteOptions, WSRouteHandler } from '@forklaunch/hyper-express-fork';
5
4
  export { MiddlewareNext as NextFunction, Request, Response, ServerConstructorOptions } from '@forklaunch/hyper-express-fork';
5
+ import { AnySchemaValidator, Schema } from '@forklaunch/validator';
6
6
  import * as uWebsockets from 'uWebSockets.js';
7
7
  import { BusboyConfig } from 'busboy';
8
8
  export { BusboyConfig } from 'busboy';
@@ -885,5 +885,12 @@ declare const handlers: {
885
885
  put: typeof put;
886
886
  trace: typeof trace;
887
887
  };
888
+ declare const port: <SV extends AnySchemaValidator, Name extends string, ContractMethod extends Method, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>, VersionedApi extends VersionSchema<SV, ContractMethod>, RouterSession extends SessionObject<SV>, BaseRequest, BaseResponse, NextFunction, Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>, RouterHandler>(options: {
889
+ method: ContractMethod;
890
+ path: Path;
891
+ basePath: string;
892
+ schemaValidator: SV;
893
+ openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
894
+ }, contractDetailsOrMiddlewareOrTypedHandler: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>, ...middlewareOrMiddlewareAndTypedHandler: MiddlewareOrMiddlewareWithTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>[]) => MiddlewareHandler[];
888
895
 
889
- export { type App, Application, type ExpressApplicationOptions, type ExpressRouterOptions, Router, forklaunchExpress, forklaunchRouter, handlers };
896
+ export { type App, Application, type ExpressApplicationOptions, type ExpressRouterOptions, Router, forklaunchExpress, forklaunchRouter, handlers, port };
package/lib/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _forklaunch_core_http from '@forklaunch/core/http';
2
- import { ParamsObject, ResponsesObject, Body, QueryObject, HeadersObject, VersionSchema, SchemaAuthMethods, ContractDetails, ExpressLikeSchemaHandler, ResolvedSessionObject, SessionObject, ExpressLikeApplicationOptions, ExpressLikeRouterOptions, ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefinition, ParsedQs, StringOnlyObject, MiddlewareContractDetails, PathMatch, TypedHandler, ForklaunchExpressLikeRouter, ForklaunchRouter, TypedMiddlewareDefinition } from '@forklaunch/core/http';
3
- import { AnySchemaValidator, Schema } from '@forklaunch/validator';
2
+ import { ParamsObject, ResponsesObject, Body, QueryObject, HeadersObject, VersionSchema, SchemaAuthMethods, ContractDetails, ExpressLikeSchemaHandler, ResolvedSessionObject, SessionObject, ExpressLikeApplicationOptions, ExpressLikeRouterOptions, ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefinition, ParsedQs, StringOnlyObject, MiddlewareContractDetails, PathMatch, TypedHandler, ForklaunchExpressLikeRouter, ForklaunchRouter, TypedMiddlewareDefinition, Method, ContractDetailsOrMiddlewareOrTypedHandler, MiddlewareOrMiddlewareWithTypedHandler } from '@forklaunch/core/http';
4
3
  import { Request, Response, MiddlewareNext, ServerConstructorOptions, Server, MiddlewareHandler, Router as Router$1, WSRouteOptions, WSRouteHandler } from '@forklaunch/hyper-express-fork';
5
4
  export { MiddlewareNext as NextFunction, Request, Response, ServerConstructorOptions } from '@forklaunch/hyper-express-fork';
5
+ import { AnySchemaValidator, Schema } from '@forklaunch/validator';
6
6
  import * as uWebsockets from 'uWebSockets.js';
7
7
  import { BusboyConfig } from 'busboy';
8
8
  export { BusboyConfig } from 'busboy';
@@ -885,5 +885,12 @@ declare const handlers: {
885
885
  put: typeof put;
886
886
  trace: typeof trace;
887
887
  };
888
+ declare const port: <SV extends AnySchemaValidator, Name extends string, ContractMethod extends Method, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>, VersionedApi extends VersionSchema<SV, ContractMethod>, RouterSession extends SessionObject<SV>, BaseRequest, BaseResponse, NextFunction, Auth extends SchemaAuthMethods<SV, P, ReqBody, ReqQuery, ReqHeaders, VersionedApi, BaseRequest>, RouterHandler>(options: {
889
+ method: ContractMethod;
890
+ path: Path;
891
+ basePath: string;
892
+ schemaValidator: SV;
893
+ openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
894
+ }, contractDetailsOrMiddlewareOrTypedHandler: ContractDetailsOrMiddlewareOrTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>, ...middlewareOrMiddlewareAndTypedHandler: MiddlewareOrMiddlewareWithTypedHandler<SV, Name, ContractMethod, Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, VersionedApi, BaseRequest, BaseResponse, NextFunction, RouterSession, Auth>[]) => MiddlewareHandler[];
888
895
 
889
- export { type App, Application, type ExpressApplicationOptions, type ExpressRouterOptions, Router, forklaunchExpress, forklaunchRouter, handlers };
896
+ export { type App, Application, type ExpressApplicationOptions, type ExpressRouterOptions, Router, forklaunchExpress, forklaunchRouter, handlers, port };
package/lib/index.js CHANGED
@@ -32,9 +32,11 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  forklaunchExpress: () => forklaunchExpress,
34
34
  forklaunchRouter: () => forklaunchRouter,
35
- handlers: () => handlers
35
+ handlers: () => handlers,
36
+ port: () => port
36
37
  });
37
38
  module.exports = __toCommonJS(index_exports);
39
+ var import_http15 = require("@forklaunch/core/http");
38
40
 
39
41
  // src/handlers/any.ts
40
42
  var import_http = require("@forklaunch/core/http");
@@ -486,7 +488,7 @@ var Application = class extends import_http13.ForklaunchExpressLikeApplication {
486
488
  process.exit(0);
487
489
  }
488
490
  if (typeof arg0 === "number") {
489
- const port = arg0 || Number(process.env.PORT);
491
+ const port2 = arg0 || Number(process.env.PORT);
490
492
  const protocol = process.env.PROTOCOL || "http";
491
493
  const host = typeof arg1 === "string" ? arg1 : process.env.HOST || "0.0.0.0";
492
494
  this.internal.set_error_handler((req, res, err) => {
@@ -516,12 +518,12 @@ Correlation id: ${(0, import_http13.isForklaunchRequest)(req) ? req.context.corr
516
518
  contentTypeMapping
517
519
  } = this.mcpConfiguration ?? {};
518
520
  const zodSchemaValidator = this.schemaValidator;
519
- const finalMcpPort = mcpPort ?? port + 2e3;
521
+ const finalMcpPort = mcpPort ?? port2 + 2e3;
520
522
  const mcpServer = (0, import_http13.generateMcpServer)(
521
523
  zodSchemaValidator,
522
524
  protocol,
523
525
  host,
524
- port,
526
+ port2,
525
527
  version ?? "1.0.0",
526
528
  this,
527
529
  this.mcpConfiguration,
@@ -557,7 +559,7 @@ Correlation id: ${(0, import_http13.isForklaunchRequest)(req) ? req.context.corr
557
559
  }
558
560
  if (this.openapiConfiguration !== false) {
559
561
  const openApiServerUrls = (0, import_common3.getEnvVar)("DOCS_SERVER_URLS")?.split(",") ?? [
560
- `${protocol}://${host}:${port}`
562
+ `${protocol}://${host}:${port2}`
561
563
  ];
562
564
  const openApiServerDescriptions = (0, import_common3.getEnvVar)(
563
565
  "DOCS_SERVER_DESCRIPTIONS"
@@ -655,7 +657,7 @@ Correlation id: ${(0, import_http13.isForklaunchRequest)(req) ? req.context.corr
655
657
  startHyperExpressCluster({
656
658
  expressApp: this.internal,
657
659
  openTelemetryCollector: this.openTelemetryCollector,
658
- port,
660
+ port: port2,
659
661
  host,
660
662
  workerCount,
661
663
  routingStrategy,
@@ -663,9 +665,9 @@ Correlation id: ${(0, import_http13.isForklaunchRequest)(req) ? req.context.corr
663
665
  });
664
666
  }
665
667
  if (arg1 && typeof arg1 === "string") {
666
- return this.internal.listen(port, arg1, arg2);
668
+ return this.internal.listen(port2, arg1, arg2);
667
669
  } else if (arg1 && typeof arg1 === "function") {
668
- return this.internal.listen(port, arg1);
670
+ return this.internal.listen(port2, arg1);
669
671
  }
670
672
  }
671
673
  return this.internal.listen(
@@ -771,9 +773,21 @@ var handlers = {
771
773
  put,
772
774
  trace
773
775
  };
776
+ var port = (options2, contractDetailsOrMiddlewareOrTypedHandler, ...middlewareOrMiddlewareAndTypedHandler) => {
777
+ const handlers2 = (0, import_http15.extractRouteHandlers)({
778
+ ...options2,
779
+ contractDetailsOrMiddlewareOrTypedHandler,
780
+ middlewareOrMiddlewareAndTypedHandler
781
+ });
782
+ return [
783
+ ...handlers2.middlewares,
784
+ handlers2.controllerHandler
785
+ ];
786
+ };
774
787
  // Annotate the CommonJS export names for ESM import in node:
775
788
  0 && (module.exports = {
776
789
  forklaunchExpress,
777
790
  forklaunchRouter,
778
- handlers
791
+ handlers,
792
+ port
779
793
  });
package/lib/index.mjs CHANGED
@@ -1,3 +1,8 @@
1
+ // index.ts
2
+ import {
3
+ extractRouteHandlers
4
+ } from "@forklaunch/core/http";
5
+
1
6
  // src/handlers/any.ts
2
7
  import {
3
8
  middleware
@@ -480,7 +485,7 @@ var Application = class extends ForklaunchExpressLikeApplication {
480
485
  process.exit(0);
481
486
  }
482
487
  if (typeof arg0 === "number") {
483
- const port = arg0 || Number(process.env.PORT);
488
+ const port2 = arg0 || Number(process.env.PORT);
484
489
  const protocol = process.env.PROTOCOL || "http";
485
490
  const host = typeof arg1 === "string" ? arg1 : process.env.HOST || "0.0.0.0";
486
491
  this.internal.set_error_handler((req, res, err) => {
@@ -510,12 +515,12 @@ Correlation id: ${isForklaunchRequest(req) ? req.context.correlationId : "No cor
510
515
  contentTypeMapping
511
516
  } = this.mcpConfiguration ?? {};
512
517
  const zodSchemaValidator = this.schemaValidator;
513
- const finalMcpPort = mcpPort ?? port + 2e3;
518
+ const finalMcpPort = mcpPort ?? port2 + 2e3;
514
519
  const mcpServer = generateMcpServer(
515
520
  zodSchemaValidator,
516
521
  protocol,
517
522
  host,
518
- port,
523
+ port2,
519
524
  version ?? "1.0.0",
520
525
  this,
521
526
  this.mcpConfiguration,
@@ -551,7 +556,7 @@ Correlation id: ${isForklaunchRequest(req) ? req.context.correlationId : "No cor
551
556
  }
552
557
  if (this.openapiConfiguration !== false) {
553
558
  const openApiServerUrls = getEnvVar("DOCS_SERVER_URLS")?.split(",") ?? [
554
- `${protocol}://${host}:${port}`
559
+ `${protocol}://${host}:${port2}`
555
560
  ];
556
561
  const openApiServerDescriptions = getEnvVar(
557
562
  "DOCS_SERVER_DESCRIPTIONS"
@@ -649,7 +654,7 @@ Correlation id: ${isForklaunchRequest(req) ? req.context.correlationId : "No cor
649
654
  startHyperExpressCluster({
650
655
  expressApp: this.internal,
651
656
  openTelemetryCollector: this.openTelemetryCollector,
652
- port,
657
+ port: port2,
653
658
  host,
654
659
  workerCount,
655
660
  routingStrategy,
@@ -657,9 +662,9 @@ Correlation id: ${isForklaunchRequest(req) ? req.context.correlationId : "No cor
657
662
  });
658
663
  }
659
664
  if (arg1 && typeof arg1 === "string") {
660
- return this.internal.listen(port, arg1, arg2);
665
+ return this.internal.listen(port2, arg1, arg2);
661
666
  } else if (arg1 && typeof arg1 === "function") {
662
- return this.internal.listen(port, arg1);
667
+ return this.internal.listen(port2, arg1);
663
668
  }
664
669
  }
665
670
  return this.internal.listen(
@@ -769,8 +774,20 @@ var handlers = {
769
774
  put,
770
775
  trace
771
776
  };
777
+ var port = (options2, contractDetailsOrMiddlewareOrTypedHandler, ...middlewareOrMiddlewareAndTypedHandler) => {
778
+ const handlers2 = extractRouteHandlers({
779
+ ...options2,
780
+ contractDetailsOrMiddlewareOrTypedHandler,
781
+ middlewareOrMiddlewareAndTypedHandler
782
+ });
783
+ return [
784
+ ...handlers2.middlewares,
785
+ handlers2.controllerHandler
786
+ ];
787
+ };
772
788
  export {
773
789
  forklaunchExpress,
774
790
  forklaunchRouter,
775
- handlers
791
+ handlers,
792
+ port
776
793
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/hyper-express",
3
- "version": "0.10.2",
3
+ "version": "0.11.1",
4
4
  "description": "Forklaunch framework for hyper-express.",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -26,38 +26,38 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@forklaunch/hyper-express-fork": "^6.17.35",
29
- "@scalar/express-api-reference": "^0.8.24",
29
+ "@scalar/express-api-reference": "^0.8.34",
30
30
  "cors": "^2.8.5",
31
31
  "live-directory": "^3.0.3",
32
32
  "openapi3-ts": "^4.5.0",
33
- "qs": "^6.14.0",
34
- "swagger-ui-dist": "^5.30.2",
33
+ "qs": "^6.14.1",
34
+ "swagger-ui-dist": "^5.31.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.23",
38
- "@forklaunch/validator": "0.10.23",
39
- "@forklaunch/core": "0.16.1",
40
- "@forklaunch/ws": "0.1.2"
37
+ "@forklaunch/common": "0.6.25",
38
+ "@forklaunch/core": "0.17.1",
39
+ "@forklaunch/ws": "0.1.4",
40
+ "@forklaunch/validator": "0.10.25"
41
41
  },
42
42
  "devDependencies": {
43
- "@eslint/js": "^9.39.1",
43
+ "@eslint/js": "^9.39.2",
44
44
  "@types/busboy": "^1.5.4",
45
45
  "@types/cors": "^2.8.19",
46
46
  "@types/jest": "^30.0.0",
47
47
  "@types/qs": "^6.14.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.20251117.1",
50
+ "@typescript/native-preview": "7.0.0-dev.20260118.1",
51
51
  "jest": "^30.2.0",
52
52
  "kill-port-process": "^3.2.1",
53
- "prettier": "^3.6.2",
54
- "ts-jest": "^29.4.5",
53
+ "prettier": "^3.8.0",
54
+ "ts-jest": "^29.4.6",
55
55
  "ts-node": "^10.9.2",
56
56
  "tsup": "^8.5.1",
57
- "tsx": "^4.20.6",
58
- "typedoc": "^0.28.14",
57
+ "tsx": "^4.21.0",
58
+ "typedoc": "^0.28.16",
59
59
  "typescript": "^5.9.3",
60
- "typescript-eslint": "^8.46.4"
60
+ "typescript-eslint": "^8.53.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",