@forklaunch/express 0.9.33 → 0.10.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 +10 -3
- package/lib/index.d.ts +10 -3
- package/lib/index.js +33 -18
- package/lib/index.mjs +35 -17
- package/package.json +19 -19
package/lib/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _forklaunch_core_http from '@forklaunch/core/http';
|
|
2
|
-
import { SessionObject, ExpressLikeApplicationOptions, ExpressLikeRouterOptions, ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefinition, ParsedQs, ForklaunchExpressLikeRouter,
|
|
2
|
+
import { SessionObject, ExpressLikeApplicationOptions, ExpressLikeRouterOptions, ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefinition, ParsedQs, ForklaunchExpressLikeRouter, TypedMiddlewareDefinition, ParamsObject, ResponsesObject, Body, QueryObject, HeadersObject, VersionSchema, SchemaAuthMethods, ContractDetails, ExpressLikeSchemaHandler, ResolvedSessionObject, Method, ContractDetailsOrMiddlewareOrTypedHandler, MiddlewareOrMiddlewareWithTypedHandler } from '@forklaunch/core/http';
|
|
3
3
|
export { DocsConfiguration, ParsedQs } from '@forklaunch/core/http';
|
|
4
4
|
import { AnySchemaValidator, LiteralSchema, IdiomaticSchema, SchemaResolve } from '@forklaunch/validator';
|
|
5
5
|
import { Express, RequestHandler, Request, Response, NextFunction, Router as Router$1 } from 'express';
|
|
@@ -107,7 +107,7 @@ type ExpressRequestHandler = (req: Omit<Request, 'query' | 'headers'> & {
|
|
|
107
107
|
* @template SV - A type that extends AnySchemaValidator.
|
|
108
108
|
* @implements {ForklaunchRouter<SV>}
|
|
109
109
|
*/
|
|
110
|
-
declare class Router<SV extends AnySchemaValidator, BasePath extends `/${string}`, RouterSession extends SessionObject<SV>> extends ForklaunchExpressLikeRouter<SV, BasePath, RequestHandler$1, Router$1, Request, Response, NextFunction, RouterSession>
|
|
110
|
+
declare class Router<SV extends AnySchemaValidator, BasePath extends `/${string}`, RouterSession extends SessionObject<SV>> extends ForklaunchExpressLikeRouter<SV, BasePath, RequestHandler$1, Router$1, Request, Response, NextFunction, RouterSession> {
|
|
111
111
|
basePath: BasePath;
|
|
112
112
|
private configOptions;
|
|
113
113
|
/**
|
|
@@ -2101,5 +2101,12 @@ declare const handlers: {
|
|
|
2101
2101
|
unlock: typeof unlock;
|
|
2102
2102
|
unsubscribe: typeof unsubscribe;
|
|
2103
2103
|
};
|
|
2104
|
+
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: {
|
|
2105
|
+
method: ContractMethod;
|
|
2106
|
+
path: Path;
|
|
2107
|
+
basePath: string;
|
|
2108
|
+
schemaValidator: SV;
|
|
2109
|
+
openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
|
|
2110
|
+
}, 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>[]) => RequestHandler[];
|
|
2104
2111
|
|
|
2105
|
-
export { Application, type ExpressApplicationOptions, type ExpressRouterOptions, Router, forklaunchExpress, forklaunchRouter, handlers };
|
|
2112
|
+
export { Application, type ExpressApplicationOptions, type ExpressRouterOptions, Router, forklaunchExpress, forklaunchRouter, handlers, port };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _forklaunch_core_http from '@forklaunch/core/http';
|
|
2
|
-
import { SessionObject, ExpressLikeApplicationOptions, ExpressLikeRouterOptions, ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefinition, ParsedQs, ForklaunchExpressLikeRouter,
|
|
2
|
+
import { SessionObject, ExpressLikeApplicationOptions, ExpressLikeRouterOptions, ForklaunchExpressLikeApplication, OpenTelemetryCollector, MetricsDefinition, ParsedQs, ForklaunchExpressLikeRouter, TypedMiddlewareDefinition, ParamsObject, ResponsesObject, Body, QueryObject, HeadersObject, VersionSchema, SchemaAuthMethods, ContractDetails, ExpressLikeSchemaHandler, ResolvedSessionObject, Method, ContractDetailsOrMiddlewareOrTypedHandler, MiddlewareOrMiddlewareWithTypedHandler } from '@forklaunch/core/http';
|
|
3
3
|
export { DocsConfiguration, ParsedQs } from '@forklaunch/core/http';
|
|
4
4
|
import { AnySchemaValidator, LiteralSchema, IdiomaticSchema, SchemaResolve } from '@forklaunch/validator';
|
|
5
5
|
import { Express, RequestHandler, Request, Response, NextFunction, Router as Router$1 } from 'express';
|
|
@@ -107,7 +107,7 @@ type ExpressRequestHandler = (req: Omit<Request, 'query' | 'headers'> & {
|
|
|
107
107
|
* @template SV - A type that extends AnySchemaValidator.
|
|
108
108
|
* @implements {ForklaunchRouter<SV>}
|
|
109
109
|
*/
|
|
110
|
-
declare class Router<SV extends AnySchemaValidator, BasePath extends `/${string}`, RouterSession extends SessionObject<SV>> extends ForklaunchExpressLikeRouter<SV, BasePath, RequestHandler$1, Router$1, Request, Response, NextFunction, RouterSession>
|
|
110
|
+
declare class Router<SV extends AnySchemaValidator, BasePath extends `/${string}`, RouterSession extends SessionObject<SV>> extends ForklaunchExpressLikeRouter<SV, BasePath, RequestHandler$1, Router$1, Request, Response, NextFunction, RouterSession> {
|
|
111
111
|
basePath: BasePath;
|
|
112
112
|
private configOptions;
|
|
113
113
|
/**
|
|
@@ -2101,5 +2101,12 @@ declare const handlers: {
|
|
|
2101
2101
|
unlock: typeof unlock;
|
|
2102
2102
|
unsubscribe: typeof unsubscribe;
|
|
2103
2103
|
};
|
|
2104
|
+
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: {
|
|
2105
|
+
method: ContractMethod;
|
|
2106
|
+
path: Path;
|
|
2107
|
+
basePath: string;
|
|
2108
|
+
schemaValidator: SV;
|
|
2109
|
+
openTelemetryCollector?: OpenTelemetryCollector<MetricsDefinition>;
|
|
2110
|
+
}, 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>[]) => RequestHandler[];
|
|
2104
2111
|
|
|
2105
|
-
export { Application, type ExpressApplicationOptions, type ExpressRouterOptions, Router, forklaunchExpress, forklaunchRouter, handlers };
|
|
2112
|
+
export { 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_http33 = require("@forklaunch/core/http");
|
|
38
40
|
|
|
39
41
|
// src/expressApplication.ts
|
|
40
42
|
var import_common4 = require("@forklaunch/common");
|
|
@@ -190,11 +192,11 @@ var BunSocketShim = class extends import_stream.Duplex {
|
|
|
190
192
|
this.end();
|
|
191
193
|
}
|
|
192
194
|
connect(optionsPortOrPath, hostOrConnectionListener, connectionListener) {
|
|
193
|
-
let
|
|
195
|
+
let port2;
|
|
194
196
|
let host;
|
|
195
197
|
let listener;
|
|
196
198
|
if (typeof optionsPortOrPath === "number") {
|
|
197
|
-
|
|
199
|
+
port2 = optionsPortOrPath;
|
|
198
200
|
if (typeof hostOrConnectionListener === "string") {
|
|
199
201
|
host = hostOrConnectionListener;
|
|
200
202
|
listener = connectionListener;
|
|
@@ -205,7 +207,7 @@ var BunSocketShim = class extends import_stream.Duplex {
|
|
|
205
207
|
host = "localhost";
|
|
206
208
|
}
|
|
207
209
|
this.remoteAddress = host;
|
|
208
|
-
this.remotePort =
|
|
210
|
+
this.remotePort = port2;
|
|
209
211
|
this.localAddress = "localhost";
|
|
210
212
|
this.localPort = 0;
|
|
211
213
|
this.remoteFamily = "IPv4";
|
|
@@ -228,10 +230,10 @@ var BunSocketShim = class extends import_stream.Duplex {
|
|
|
228
230
|
this.remoteFamily = "Unix";
|
|
229
231
|
this.localFamily = "Unix";
|
|
230
232
|
} else {
|
|
231
|
-
|
|
233
|
+
port2 = options2.port;
|
|
232
234
|
host = options2.host || "localhost";
|
|
233
235
|
this.remoteAddress = host;
|
|
234
|
-
this.remotePort =
|
|
236
|
+
this.remotePort = port2;
|
|
235
237
|
this.localAddress = options2.localAddress || "localhost";
|
|
236
238
|
this.localPort = options2.localPort || 0;
|
|
237
239
|
this.remoteFamily = typeof options2.family === "number" ? "IPv4" : options2.family || "IPv4";
|
|
@@ -250,8 +252,8 @@ var BunSocketShim = class extends import_stream.Duplex {
|
|
|
250
252
|
this.connecting = false;
|
|
251
253
|
this.pending = false;
|
|
252
254
|
this.readyState = "open";
|
|
253
|
-
if (
|
|
254
|
-
this.remotePort =
|
|
255
|
+
if (port2 !== void 0) {
|
|
256
|
+
this.remotePort = port2;
|
|
255
257
|
}
|
|
256
258
|
if (host !== void 0) {
|
|
257
259
|
this.remoteAddress = host;
|
|
@@ -488,7 +490,7 @@ function parseSignedCookies(request, secret) {
|
|
|
488
490
|
}
|
|
489
491
|
function serveExpress(app, openTelemetryCollector, opts = {}) {
|
|
490
492
|
const {
|
|
491
|
-
port = Number(process.env.PORT || 3e3),
|
|
493
|
+
port: port2 = Number(process.env.PORT || 3e3),
|
|
492
494
|
host = "0.0.0.0",
|
|
493
495
|
reusePort = false,
|
|
494
496
|
development = process.env.NODE_ENV !== "production",
|
|
@@ -498,7 +500,7 @@ function serveExpress(app, openTelemetryCollector, opts = {}) {
|
|
|
498
500
|
} = opts;
|
|
499
501
|
let serverClosed = false;
|
|
500
502
|
const server = Bun.serve({
|
|
501
|
-
port,
|
|
503
|
+
port: port2,
|
|
502
504
|
hostname: host,
|
|
503
505
|
reusePort,
|
|
504
506
|
development,
|
|
@@ -519,7 +521,7 @@ function serveExpress(app, openTelemetryCollector, opts = {}) {
|
|
|
519
521
|
let socketTimeoutId;
|
|
520
522
|
const socket = createSocketFromBunRequest(request, {
|
|
521
523
|
hostname: host,
|
|
522
|
-
port
|
|
524
|
+
port: port2
|
|
523
525
|
});
|
|
524
526
|
let ended = false;
|
|
525
527
|
const headerMap = new Headers();
|
|
@@ -2092,7 +2094,7 @@ var Application = class extends import_http3.ForklaunchExpressLikeApplication {
|
|
|
2092
2094
|
);
|
|
2093
2095
|
process.exit(0);
|
|
2094
2096
|
}
|
|
2095
|
-
const
|
|
2097
|
+
const port2 = typeof args[0] === "number" ? args[0] : Number(process.env.PORT);
|
|
2096
2098
|
const host = typeof args[1] === "string" ? args[1] : process.env.HOST ?? "localhost";
|
|
2097
2099
|
const protocol = process.env.PROTOCOL ?? "http";
|
|
2098
2100
|
if (this.schemaValidator instanceof import_zod.ZodSchemaValidator && this.mcpConfiguration !== false) {
|
|
@@ -2106,12 +2108,12 @@ var Application = class extends import_http3.ForklaunchExpressLikeApplication {
|
|
|
2106
2108
|
authenticate
|
|
2107
2109
|
} = this.mcpConfiguration ?? {};
|
|
2108
2110
|
const zodSchemaValidator = this.schemaValidator;
|
|
2109
|
-
const finalMcpPort = mcpPort ??
|
|
2111
|
+
const finalMcpPort = mcpPort ?? port2 + 2e3;
|
|
2110
2112
|
const mcpServer = (0, import_http3.generateMcpServer)(
|
|
2111
2113
|
zodSchemaValidator,
|
|
2112
2114
|
protocol,
|
|
2113
2115
|
host,
|
|
2114
|
-
|
|
2116
|
+
port2,
|
|
2115
2117
|
version ?? "1.0.0",
|
|
2116
2118
|
this,
|
|
2117
2119
|
this.mcpConfiguration,
|
|
@@ -2148,7 +2150,7 @@ var Application = class extends import_http3.ForklaunchExpressLikeApplication {
|
|
|
2148
2150
|
}
|
|
2149
2151
|
if (this.openapiConfiguration !== false) {
|
|
2150
2152
|
const openApiServerUrls = (0, import_common4.getEnvVar)("DOCS_SERVER_URLS")?.split(",") ?? [
|
|
2151
|
-
`${protocol}://${host}:${
|
|
2153
|
+
`${protocol}://${host}:${port2}`
|
|
2152
2154
|
];
|
|
2153
2155
|
const openApiServerDescriptions = (0, import_common4.getEnvVar)(
|
|
2154
2156
|
"DOCS_SERVER_DESCRIPTIONS"
|
|
@@ -2271,7 +2273,7 @@ Correlation id: ${(0, import_http3.isForklaunchRequest)(req) ? req.context.corre
|
|
|
2271
2273
|
startBunCluster({
|
|
2272
2274
|
expressApp: this.internal,
|
|
2273
2275
|
openTelemetryCollector: this.openTelemetryCollector,
|
|
2274
|
-
port,
|
|
2276
|
+
port: port2,
|
|
2275
2277
|
host,
|
|
2276
2278
|
workerCount,
|
|
2277
2279
|
routingStrategy,
|
|
@@ -2281,7 +2283,7 @@ Correlation id: ${(0, import_http3.isForklaunchRequest)(req) ? req.context.corre
|
|
|
2281
2283
|
startNodeCluster({
|
|
2282
2284
|
expressApp: this.internal,
|
|
2283
2285
|
openTelemetryCollector: this.openTelemetryCollector,
|
|
2284
|
-
port,
|
|
2286
|
+
port: port2,
|
|
2285
2287
|
host,
|
|
2286
2288
|
workerCount,
|
|
2287
2289
|
routingStrategy,
|
|
@@ -2318,6 +2320,7 @@ var Router = class _Router extends import_http4.ForklaunchExpressLikeRouter {
|
|
|
2318
2320
|
this.basePath = basePath;
|
|
2319
2321
|
this.configOptions = options2;
|
|
2320
2322
|
}
|
|
2323
|
+
// implements ForklaunchRouter<SV>
|
|
2321
2324
|
configOptions;
|
|
2322
2325
|
route(path2) {
|
|
2323
2326
|
this.internal.route(path2);
|
|
@@ -2714,9 +2717,21 @@ var handlers = {
|
|
|
2714
2717
|
unlock,
|
|
2715
2718
|
unsubscribe
|
|
2716
2719
|
};
|
|
2720
|
+
var port = (options2, contractDetailsOrMiddlewareOrTypedHandler, ...middlewareOrMiddlewareAndTypedHandler) => {
|
|
2721
|
+
const handlers2 = (0, import_http33.extractRouteHandlers)({
|
|
2722
|
+
...options2,
|
|
2723
|
+
contractDetailsOrMiddlewareOrTypedHandler,
|
|
2724
|
+
middlewareOrMiddlewareAndTypedHandler
|
|
2725
|
+
});
|
|
2726
|
+
return [
|
|
2727
|
+
...handlers2.middlewares,
|
|
2728
|
+
handlers2.controllerHandler
|
|
2729
|
+
];
|
|
2730
|
+
};
|
|
2717
2731
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2718
2732
|
0 && (module.exports = {
|
|
2719
2733
|
forklaunchExpress,
|
|
2720
2734
|
forklaunchRouter,
|
|
2721
|
-
handlers
|
|
2735
|
+
handlers,
|
|
2736
|
+
port
|
|
2722
2737
|
});
|
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/expressApplication.ts
|
|
2
7
|
import { getEnvVar, safeStringify as safeStringify2 } from "@forklaunch/common";
|
|
3
8
|
import {
|
|
@@ -161,11 +166,11 @@ var BunSocketShim = class extends Duplex {
|
|
|
161
166
|
this.end();
|
|
162
167
|
}
|
|
163
168
|
connect(optionsPortOrPath, hostOrConnectionListener, connectionListener) {
|
|
164
|
-
let
|
|
169
|
+
let port2;
|
|
165
170
|
let host;
|
|
166
171
|
let listener;
|
|
167
172
|
if (typeof optionsPortOrPath === "number") {
|
|
168
|
-
|
|
173
|
+
port2 = optionsPortOrPath;
|
|
169
174
|
if (typeof hostOrConnectionListener === "string") {
|
|
170
175
|
host = hostOrConnectionListener;
|
|
171
176
|
listener = connectionListener;
|
|
@@ -176,7 +181,7 @@ var BunSocketShim = class extends Duplex {
|
|
|
176
181
|
host = "localhost";
|
|
177
182
|
}
|
|
178
183
|
this.remoteAddress = host;
|
|
179
|
-
this.remotePort =
|
|
184
|
+
this.remotePort = port2;
|
|
180
185
|
this.localAddress = "localhost";
|
|
181
186
|
this.localPort = 0;
|
|
182
187
|
this.remoteFamily = "IPv4";
|
|
@@ -199,10 +204,10 @@ var BunSocketShim = class extends Duplex {
|
|
|
199
204
|
this.remoteFamily = "Unix";
|
|
200
205
|
this.localFamily = "Unix";
|
|
201
206
|
} else {
|
|
202
|
-
|
|
207
|
+
port2 = options2.port;
|
|
203
208
|
host = options2.host || "localhost";
|
|
204
209
|
this.remoteAddress = host;
|
|
205
|
-
this.remotePort =
|
|
210
|
+
this.remotePort = port2;
|
|
206
211
|
this.localAddress = options2.localAddress || "localhost";
|
|
207
212
|
this.localPort = options2.localPort || 0;
|
|
208
213
|
this.remoteFamily = typeof options2.family === "number" ? "IPv4" : options2.family || "IPv4";
|
|
@@ -221,8 +226,8 @@ var BunSocketShim = class extends Duplex {
|
|
|
221
226
|
this.connecting = false;
|
|
222
227
|
this.pending = false;
|
|
223
228
|
this.readyState = "open";
|
|
224
|
-
if (
|
|
225
|
-
this.remotePort =
|
|
229
|
+
if (port2 !== void 0) {
|
|
230
|
+
this.remotePort = port2;
|
|
226
231
|
}
|
|
227
232
|
if (host !== void 0) {
|
|
228
233
|
this.remoteAddress = host;
|
|
@@ -459,7 +464,7 @@ function parseSignedCookies(request, secret) {
|
|
|
459
464
|
}
|
|
460
465
|
function serveExpress(app, openTelemetryCollector, opts = {}) {
|
|
461
466
|
const {
|
|
462
|
-
port = Number(process.env.PORT || 3e3),
|
|
467
|
+
port: port2 = Number(process.env.PORT || 3e3),
|
|
463
468
|
host = "0.0.0.0",
|
|
464
469
|
reusePort = false,
|
|
465
470
|
development = process.env.NODE_ENV !== "production",
|
|
@@ -469,7 +474,7 @@ function serveExpress(app, openTelemetryCollector, opts = {}) {
|
|
|
469
474
|
} = opts;
|
|
470
475
|
let serverClosed = false;
|
|
471
476
|
const server = Bun.serve({
|
|
472
|
-
port,
|
|
477
|
+
port: port2,
|
|
473
478
|
hostname: host,
|
|
474
479
|
reusePort,
|
|
475
480
|
development,
|
|
@@ -490,7 +495,7 @@ function serveExpress(app, openTelemetryCollector, opts = {}) {
|
|
|
490
495
|
let socketTimeoutId;
|
|
491
496
|
const socket = createSocketFromBunRequest(request, {
|
|
492
497
|
hostname: host,
|
|
493
|
-
port
|
|
498
|
+
port: port2
|
|
494
499
|
});
|
|
495
500
|
let ended = false;
|
|
496
501
|
const headerMap = new Headers();
|
|
@@ -2065,7 +2070,7 @@ var Application = class extends ForklaunchExpressLikeApplication {
|
|
|
2065
2070
|
);
|
|
2066
2071
|
process.exit(0);
|
|
2067
2072
|
}
|
|
2068
|
-
const
|
|
2073
|
+
const port2 = typeof args[0] === "number" ? args[0] : Number(process.env.PORT);
|
|
2069
2074
|
const host = typeof args[1] === "string" ? args[1] : process.env.HOST ?? "localhost";
|
|
2070
2075
|
const protocol = process.env.PROTOCOL ?? "http";
|
|
2071
2076
|
if (this.schemaValidator instanceof ZodSchemaValidator && this.mcpConfiguration !== false) {
|
|
@@ -2079,12 +2084,12 @@ var Application = class extends ForklaunchExpressLikeApplication {
|
|
|
2079
2084
|
authenticate
|
|
2080
2085
|
} = this.mcpConfiguration ?? {};
|
|
2081
2086
|
const zodSchemaValidator = this.schemaValidator;
|
|
2082
|
-
const finalMcpPort = mcpPort ??
|
|
2087
|
+
const finalMcpPort = mcpPort ?? port2 + 2e3;
|
|
2083
2088
|
const mcpServer = generateMcpServer(
|
|
2084
2089
|
zodSchemaValidator,
|
|
2085
2090
|
protocol,
|
|
2086
2091
|
host,
|
|
2087
|
-
|
|
2092
|
+
port2,
|
|
2088
2093
|
version ?? "1.0.0",
|
|
2089
2094
|
this,
|
|
2090
2095
|
this.mcpConfiguration,
|
|
@@ -2121,7 +2126,7 @@ var Application = class extends ForklaunchExpressLikeApplication {
|
|
|
2121
2126
|
}
|
|
2122
2127
|
if (this.openapiConfiguration !== false) {
|
|
2123
2128
|
const openApiServerUrls = getEnvVar("DOCS_SERVER_URLS")?.split(",") ?? [
|
|
2124
|
-
`${protocol}://${host}:${
|
|
2129
|
+
`${protocol}://${host}:${port2}`
|
|
2125
2130
|
];
|
|
2126
2131
|
const openApiServerDescriptions = getEnvVar(
|
|
2127
2132
|
"DOCS_SERVER_DESCRIPTIONS"
|
|
@@ -2244,7 +2249,7 @@ Correlation id: ${isForklaunchRequest(req) ? req.context.correlationId : "No cor
|
|
|
2244
2249
|
startBunCluster({
|
|
2245
2250
|
expressApp: this.internal,
|
|
2246
2251
|
openTelemetryCollector: this.openTelemetryCollector,
|
|
2247
|
-
port,
|
|
2252
|
+
port: port2,
|
|
2248
2253
|
host,
|
|
2249
2254
|
workerCount,
|
|
2250
2255
|
routingStrategy,
|
|
@@ -2254,7 +2259,7 @@ Correlation id: ${isForklaunchRequest(req) ? req.context.correlationId : "No cor
|
|
|
2254
2259
|
startNodeCluster({
|
|
2255
2260
|
expressApp: this.internal,
|
|
2256
2261
|
openTelemetryCollector: this.openTelemetryCollector,
|
|
2257
|
-
port,
|
|
2262
|
+
port: port2,
|
|
2258
2263
|
host,
|
|
2259
2264
|
workerCount,
|
|
2260
2265
|
routingStrategy,
|
|
@@ -2293,6 +2298,7 @@ var Router = class _Router extends ForklaunchExpressLikeRouter {
|
|
|
2293
2298
|
this.basePath = basePath;
|
|
2294
2299
|
this.configOptions = options2;
|
|
2295
2300
|
}
|
|
2301
|
+
// implements ForklaunchRouter<SV>
|
|
2296
2302
|
configOptions;
|
|
2297
2303
|
route(path2) {
|
|
2298
2304
|
this.internal.route(path2);
|
|
@@ -2745,8 +2751,20 @@ var handlers = {
|
|
|
2745
2751
|
unlock,
|
|
2746
2752
|
unsubscribe
|
|
2747
2753
|
};
|
|
2754
|
+
var port = (options2, contractDetailsOrMiddlewareOrTypedHandler, ...middlewareOrMiddlewareAndTypedHandler) => {
|
|
2755
|
+
const handlers2 = extractRouteHandlers({
|
|
2756
|
+
...options2,
|
|
2757
|
+
contractDetailsOrMiddlewareOrTypedHandler,
|
|
2758
|
+
middlewareOrMiddlewareAndTypedHandler
|
|
2759
|
+
});
|
|
2760
|
+
return [
|
|
2761
|
+
...handlers2.middlewares,
|
|
2762
|
+
handlers2.controllerHandler
|
|
2763
|
+
];
|
|
2764
|
+
};
|
|
2748
2765
|
export {
|
|
2749
2766
|
forklaunchExpress,
|
|
2750
2767
|
forklaunchRouter,
|
|
2751
|
-
handlers
|
|
2768
|
+
handlers,
|
|
2769
|
+
port
|
|
2752
2770
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/express",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Forklaunch framework for express.",
|
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -25,44 +25,44 @@
|
|
|
25
25
|
"lib/**"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@scalar/express-api-reference": "^0.8.24",
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
29
|
+
"@scalar/express-api-reference": "^0.8.34",
|
|
31
30
|
"@types/multer": "^2.0.0",
|
|
32
|
-
"body-parser": "^2.2.
|
|
31
|
+
"body-parser": "^2.2.2",
|
|
33
32
|
"busboy": "^1.6.0",
|
|
34
33
|
"cors": "^2.8.5",
|
|
35
|
-
"express": "^5.1
|
|
34
|
+
"express": "^5.2.1",
|
|
35
|
+
"fastmcp": "^3.26.9",
|
|
36
36
|
"multer": "2.0.2",
|
|
37
|
-
"qs": "^6.14.
|
|
37
|
+
"qs": "^6.14.1",
|
|
38
38
|
"range-parser": "^1.2.1",
|
|
39
39
|
"swagger-ui-express": "^5.0.1",
|
|
40
|
-
"@forklaunch/common": "0.6.
|
|
41
|
-
"@forklaunch/validator": "0.10.
|
|
42
|
-
"@forklaunch/core": "0.
|
|
40
|
+
"@forklaunch/common": "0.6.25",
|
|
41
|
+
"@forklaunch/validator": "0.10.25",
|
|
42
|
+
"@forklaunch/core": "0.17.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@eslint/js": "^9.39.
|
|
45
|
+
"@eslint/js": "^9.39.2",
|
|
46
46
|
"@types/body-parser": "^1.19.6",
|
|
47
|
-
"@types/bun": "^1.3.
|
|
47
|
+
"@types/bun": "^1.3.6",
|
|
48
48
|
"@types/busboy": "^1.5.4",
|
|
49
49
|
"@types/cors": "^2.8.19",
|
|
50
|
-
"@types/express": "^5.0.
|
|
51
|
-
"@types/express-serve-static-core": "^5.1.
|
|
50
|
+
"@types/express": "^5.0.6",
|
|
51
|
+
"@types/express-serve-static-core": "^5.1.1",
|
|
52
52
|
"@types/jest": "^30.0.0",
|
|
53
53
|
"@types/qs": "^6.14.0",
|
|
54
54
|
"@types/range-parser": "^1.2.7",
|
|
55
55
|
"@types/swagger-ui-express": "^4.1.8",
|
|
56
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
56
|
+
"@typescript/native-preview": "7.0.0-dev.20260118.1",
|
|
57
57
|
"jest": "^30.2.0",
|
|
58
58
|
"kill-port-process": "^3.2.1",
|
|
59
|
-
"prettier": "^3.
|
|
60
|
-
"ts-jest": "^29.4.
|
|
59
|
+
"prettier": "^3.8.0",
|
|
60
|
+
"ts-jest": "^29.4.6",
|
|
61
61
|
"ts-node": "^10.9.2",
|
|
62
62
|
"tsup": "^8.5.1",
|
|
63
|
-
"typedoc": "^0.28.
|
|
63
|
+
"typedoc": "^0.28.16",
|
|
64
64
|
"typescript": "^5.9.3",
|
|
65
|
-
"typescript-eslint": "^8.
|
|
65
|
+
"typescript-eslint": "^8.53.0"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "tsgo --noEmit && tsup index.ts --format cjs,esm --no-splitting --tsconfig tsconfig.json --outDir lib --dts --clean",
|