@forklaunch/express 0.7.4 → 0.7.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/lib/index.d.mts +11 -13
- package/lib/index.d.ts +11 -13
- package/lib/index.js +14 -44
- package/lib/index.mjs +14 -44
- package/package.json +5 -4
package/lib/index.d.mts
CHANGED
@@ -6,22 +6,27 @@ import { OptionsText, OptionsJson, OptionsUrlencoded } from 'body-parser';
|
|
6
6
|
export { OptionsJson, OptionsText, OptionsUrlencoded } from 'body-parser';
|
7
7
|
import { BusboyConfig } from 'busboy';
|
8
8
|
export { BusboyConfig } from 'busboy';
|
9
|
-
import { CorsOptions } from 'cors';
|
10
|
-
export { CorsOptions } from 'cors';
|
11
9
|
import { Express, RequestHandler, Request, Response, NextFunction, Router as Router$1 } from 'express';
|
12
10
|
export { NextFunction, Request, Response } from 'express';
|
13
11
|
import { Server } from 'http';
|
12
|
+
import { CorsOptions } from 'cors';
|
13
|
+
export { CorsOptions } from 'cors';
|
14
|
+
import { FastMCP } from 'fastmcp';
|
14
15
|
import express__default from 'express-serve-static-core';
|
15
16
|
export * from 'express-serve-static-core';
|
16
17
|
import { ParsedQs } from 'qs';
|
17
18
|
|
18
|
-
type ExpressOptions = {
|
19
|
+
type ExpressOptions<T extends Record<string, unknown> | undefined> = {
|
19
20
|
docs?: DocsConfiguration;
|
20
21
|
busboy?: BusboyConfig;
|
21
22
|
text?: OptionsText;
|
22
23
|
json?: OptionsJson;
|
23
24
|
urlencoded?: OptionsUrlencoded;
|
24
25
|
cors?: CorsOptions;
|
26
|
+
mcp?: {
|
27
|
+
sessionAuth?: T;
|
28
|
+
options?: ConstructorParameters<typeof FastMCP<T>>[0];
|
29
|
+
};
|
25
30
|
};
|
26
31
|
|
27
32
|
/**
|
@@ -35,7 +40,7 @@ type ExpressOptions = {
|
|
35
40
|
* app.listen(3000, () => console.log('Server running on port 3000'));
|
36
41
|
* ```
|
37
42
|
*/
|
38
|
-
declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpressLikeApplication<SV, Express, RequestHandler, Request, Response, NextFunction> {
|
43
|
+
declare class Application<SV extends AnySchemaValidator, T extends Record<string, unknown> | undefined> extends ForklaunchExpressLikeApplication<SV, Express, RequestHandler, Request, Response, NextFunction> {
|
39
44
|
private docsConfiguration;
|
40
45
|
/**
|
41
46
|
* Creates an instance of Application.
|
@@ -44,7 +49,7 @@ declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpre
|
|
44
49
|
* @param {OpenTelemetryCollector<MetricsDefinition>} openTelemetryCollector - Collector for OpenTelemetry metrics.
|
45
50
|
* @param {DocsConfiguration} [docsConfiguration] - Optional configuration for API documentation (Swagger/Scalar).
|
46
51
|
*/
|
47
|
-
constructor(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, options?: ExpressOptions);
|
52
|
+
constructor(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, options?: ExpressOptions<T>);
|
48
53
|
/**
|
49
54
|
* Starts the Express server and sets up API documentation (Swagger/Scalar).
|
50
55
|
* This method is overloaded to support various ways of starting the server.
|
@@ -2039,14 +2044,7 @@ declare const unsubscribe: <SV extends AnySchemaValidator, Name extends string,
|
|
2039
2044
|
* @param {SV} schemaValidator - The schema validator.
|
2040
2045
|
* @returns {Application<SV>} - The new application instance.
|
2041
2046
|
*/
|
2042
|
-
declare function forklaunchExpress<SV extends AnySchemaValidator>(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, options?:
|
2043
|
-
docs?: DocsConfiguration;
|
2044
|
-
busboy?: BusboyConfig;
|
2045
|
-
text?: OptionsText;
|
2046
|
-
json?: OptionsJson;
|
2047
|
-
urlencoded?: OptionsUrlencoded;
|
2048
|
-
cors?: CorsOptions;
|
2049
|
-
}): Application<SV>;
|
2047
|
+
declare function forklaunchExpress<SV extends AnySchemaValidator, T extends Record<string, unknown> | undefined>(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, options?: ExpressOptions<T>): Application<SV, T>;
|
2050
2048
|
/**
|
2051
2049
|
* Creates a new instance of Router with the given base path and schema validator.
|
2052
2050
|
*
|
package/lib/index.d.ts
CHANGED
@@ -6,22 +6,27 @@ import { OptionsText, OptionsJson, OptionsUrlencoded } from 'body-parser';
|
|
6
6
|
export { OptionsJson, OptionsText, OptionsUrlencoded } from 'body-parser';
|
7
7
|
import { BusboyConfig } from 'busboy';
|
8
8
|
export { BusboyConfig } from 'busboy';
|
9
|
-
import { CorsOptions } from 'cors';
|
10
|
-
export { CorsOptions } from 'cors';
|
11
9
|
import { Express, RequestHandler, Request, Response, NextFunction, Router as Router$1 } from 'express';
|
12
10
|
export { NextFunction, Request, Response } from 'express';
|
13
11
|
import { Server } from 'http';
|
12
|
+
import { CorsOptions } from 'cors';
|
13
|
+
export { CorsOptions } from 'cors';
|
14
|
+
import { FastMCP } from 'fastmcp';
|
14
15
|
import express__default from 'express-serve-static-core';
|
15
16
|
export * from 'express-serve-static-core';
|
16
17
|
import { ParsedQs } from 'qs';
|
17
18
|
|
18
|
-
type ExpressOptions = {
|
19
|
+
type ExpressOptions<T extends Record<string, unknown> | undefined> = {
|
19
20
|
docs?: DocsConfiguration;
|
20
21
|
busboy?: BusboyConfig;
|
21
22
|
text?: OptionsText;
|
22
23
|
json?: OptionsJson;
|
23
24
|
urlencoded?: OptionsUrlencoded;
|
24
25
|
cors?: CorsOptions;
|
26
|
+
mcp?: {
|
27
|
+
sessionAuth?: T;
|
28
|
+
options?: ConstructorParameters<typeof FastMCP<T>>[0];
|
29
|
+
};
|
25
30
|
};
|
26
31
|
|
27
32
|
/**
|
@@ -35,7 +40,7 @@ type ExpressOptions = {
|
|
35
40
|
* app.listen(3000, () => console.log('Server running on port 3000'));
|
36
41
|
* ```
|
37
42
|
*/
|
38
|
-
declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpressLikeApplication<SV, Express, RequestHandler, Request, Response, NextFunction> {
|
43
|
+
declare class Application<SV extends AnySchemaValidator, T extends Record<string, unknown> | undefined> extends ForklaunchExpressLikeApplication<SV, Express, RequestHandler, Request, Response, NextFunction> {
|
39
44
|
private docsConfiguration;
|
40
45
|
/**
|
41
46
|
* Creates an instance of Application.
|
@@ -44,7 +49,7 @@ declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpre
|
|
44
49
|
* @param {OpenTelemetryCollector<MetricsDefinition>} openTelemetryCollector - Collector for OpenTelemetry metrics.
|
45
50
|
* @param {DocsConfiguration} [docsConfiguration] - Optional configuration for API documentation (Swagger/Scalar).
|
46
51
|
*/
|
47
|
-
constructor(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, options?: ExpressOptions);
|
52
|
+
constructor(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, options?: ExpressOptions<T>);
|
48
53
|
/**
|
49
54
|
* Starts the Express server and sets up API documentation (Swagger/Scalar).
|
50
55
|
* This method is overloaded to support various ways of starting the server.
|
@@ -2039,14 +2044,7 @@ declare const unsubscribe: <SV extends AnySchemaValidator, Name extends string,
|
|
2039
2044
|
* @param {SV} schemaValidator - The schema validator.
|
2040
2045
|
* @returns {Application<SV>} - The new application instance.
|
2041
2046
|
*/
|
2042
|
-
declare function forklaunchExpress<SV extends AnySchemaValidator>(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, options?:
|
2043
|
-
docs?: DocsConfiguration;
|
2044
|
-
busboy?: BusboyConfig;
|
2045
|
-
text?: OptionsText;
|
2046
|
-
json?: OptionsJson;
|
2047
|
-
urlencoded?: OptionsUrlencoded;
|
2048
|
-
cors?: CorsOptions;
|
2049
|
-
}): Application<SV>;
|
2047
|
+
declare function forklaunchExpress<SV extends AnySchemaValidator, T extends Record<string, unknown> | undefined>(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, options?: ExpressOptions<T>): Application<SV, T>;
|
2050
2048
|
/**
|
2051
2049
|
* Creates a new instance of Router with the given base path and schema validator.
|
2052
2050
|
*
|
package/lib/index.js
CHANGED
@@ -40,7 +40,6 @@ module.exports = __toCommonJS(index_exports);
|
|
40
40
|
var import_common3 = require("@forklaunch/common");
|
41
41
|
var import_http3 = require("@forklaunch/core/http");
|
42
42
|
var import_zod = require("@forklaunch/validator/zod");
|
43
|
-
var import_streamableHttp = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
44
43
|
var import_express_api_reference = require("@scalar/express-api-reference");
|
45
44
|
var import_crypto = __toESM(require("crypto"));
|
46
45
|
var import_express2 = __toESM(require("express"));
|
@@ -197,49 +196,20 @@ var Application = class extends import_http3.ForklaunchExpressLikeApplication {
|
|
197
196
|
if (this.schemaValidator instanceof import_zod.ZodSchemaValidator) {
|
198
197
|
const zodSchemaValidator = this.schemaValidator;
|
199
198
|
const routers = this.routers;
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
zodSchemaValidator,
|
215
|
-
protocol,
|
216
|
-
host,
|
217
|
-
port,
|
218
|
-
"1.0.0",
|
219
|
-
routers
|
220
|
-
);
|
221
|
-
const transport = new import_streamableHttp.StreamableHTTPServerTransport({
|
222
|
-
sessionIdGenerator: void 0
|
223
|
-
});
|
224
|
-
res.on("close", () => {
|
225
|
-
transport.close();
|
226
|
-
server.close();
|
227
|
-
});
|
228
|
-
await server.connect(transport);
|
229
|
-
await transport.handleRequest(req, res, req.body);
|
230
|
-
} catch (error) {
|
231
|
-
console.error("Error handling MCP request:", error);
|
232
|
-
if (!res.headersSent) {
|
233
|
-
res.status(500).json({
|
234
|
-
jsonrpc: "2.0",
|
235
|
-
error: {
|
236
|
-
code: -32603,
|
237
|
-
message: "Internal server error"
|
238
|
-
},
|
239
|
-
id: null
|
240
|
-
});
|
241
|
-
}
|
242
|
-
}
|
199
|
+
const mcpServer = (0, import_http3.generateMcpServer)(
|
200
|
+
zodSchemaValidator,
|
201
|
+
protocol,
|
202
|
+
host,
|
203
|
+
port,
|
204
|
+
"1.0.0",
|
205
|
+
routers
|
206
|
+
);
|
207
|
+
mcpServer.start({
|
208
|
+
httpStream: {
|
209
|
+
endpoint: "/mcp",
|
210
|
+
port: port + 1
|
211
|
+
},
|
212
|
+
transportType: "httpStream"
|
243
213
|
});
|
244
214
|
}
|
245
215
|
if (this.docsConfiguration == null || this.docsConfiguration.type === "scalar") {
|
package/lib/index.mjs
CHANGED
@@ -9,7 +9,6 @@ import {
|
|
9
9
|
meta
|
10
10
|
} from "@forklaunch/core/http";
|
11
11
|
import { ZodSchemaValidator } from "@forklaunch/validator/zod";
|
12
|
-
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
13
12
|
import { apiReference } from "@scalar/express-api-reference";
|
14
13
|
import crypto from "crypto";
|
15
14
|
import express2 from "express";
|
@@ -168,49 +167,20 @@ var Application = class extends ForklaunchExpressLikeApplication {
|
|
168
167
|
if (this.schemaValidator instanceof ZodSchemaValidator) {
|
169
168
|
const zodSchemaValidator = this.schemaValidator;
|
170
169
|
const routers = this.routers;
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
zodSchemaValidator,
|
186
|
-
protocol,
|
187
|
-
host,
|
188
|
-
port,
|
189
|
-
"1.0.0",
|
190
|
-
routers
|
191
|
-
);
|
192
|
-
const transport = new StreamableHTTPServerTransport({
|
193
|
-
sessionIdGenerator: void 0
|
194
|
-
});
|
195
|
-
res.on("close", () => {
|
196
|
-
transport.close();
|
197
|
-
server.close();
|
198
|
-
});
|
199
|
-
await server.connect(transport);
|
200
|
-
await transport.handleRequest(req, res, req.body);
|
201
|
-
} catch (error) {
|
202
|
-
console.error("Error handling MCP request:", error);
|
203
|
-
if (!res.headersSent) {
|
204
|
-
res.status(500).json({
|
205
|
-
jsonrpc: "2.0",
|
206
|
-
error: {
|
207
|
-
code: -32603,
|
208
|
-
message: "Internal server error"
|
209
|
-
},
|
210
|
-
id: null
|
211
|
-
});
|
212
|
-
}
|
213
|
-
}
|
170
|
+
const mcpServer = generateMcpServer(
|
171
|
+
zodSchemaValidator,
|
172
|
+
protocol,
|
173
|
+
host,
|
174
|
+
port,
|
175
|
+
"1.0.0",
|
176
|
+
routers
|
177
|
+
);
|
178
|
+
mcpServer.start({
|
179
|
+
httpStream: {
|
180
|
+
endpoint: "/mcp",
|
181
|
+
port: port + 1
|
182
|
+
},
|
183
|
+
transportType: "httpStream"
|
214
184
|
});
|
215
185
|
}
|
216
186
|
if (this.docsConfiguration == null || this.docsConfiguration.type === "scalar") {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@forklaunch/express",
|
3
|
-
"version": "0.7.
|
3
|
+
"version": "0.7.6",
|
4
4
|
"description": "Forklaunch framework for express.",
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
6
6
|
"bugs": {
|
@@ -32,12 +32,13 @@
|
|
32
32
|
"busboy": "^1.6.0",
|
33
33
|
"cors": "^2.8.5",
|
34
34
|
"express": "^5.1.0",
|
35
|
+
"fastmcp": "^3.8.5",
|
35
36
|
"multer": "2.0.1",
|
36
37
|
"qs": "^6.14.0",
|
37
38
|
"swagger-ui-express": "^5.0.1",
|
38
|
-
"@forklaunch/common": "0.4.
|
39
|
-
"@forklaunch/
|
40
|
-
"@forklaunch/
|
39
|
+
"@forklaunch/common": "0.4.5",
|
40
|
+
"@forklaunch/core": "0.11.6",
|
41
|
+
"@forklaunch/validator": "0.7.7"
|
41
42
|
},
|
42
43
|
"devDependencies": {
|
43
44
|
"@eslint/js": "^9.31.0",
|