@askrjs/node 0.2.2 → 0.3.0
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/index.d.ts +14 -15
- package/dist/mcp.d.ts +4 -5
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -7,13 +7,13 @@ import { ServerApp } from "@askrjs/server";
|
|
|
7
7
|
* Reserved request header containing the TCP peer address authenticated by the Node adapter.
|
|
8
8
|
* Any value supplied by the HTTP client is overwritten before application dispatch.
|
|
9
9
|
*/
|
|
10
|
-
declare const CLIENT_ADDRESS_HEADER = "x-askr-client-address";
|
|
10
|
+
export declare const CLIENT_ADDRESS_HEADER = "x-askr-client-address";
|
|
11
11
|
/** Normalizes the socket peer address used for the adapter-authenticated request header. */
|
|
12
|
-
declare function normalizeClientAddress(address: string | undefined): string;
|
|
12
|
+
export declare function normalizeClientAddress(address: string | undefined): string;
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/contracts.d.ts
|
|
15
15
|
/** Options controlling how WebSocket upgrades are handled on a Node server. */
|
|
16
|
-
interface NodeWebSocketOptions {
|
|
16
|
+
export interface NodeWebSocketOptions {
|
|
17
17
|
/** Milliseconds to wait for a peer to acknowledge a close handshake before the socket is force-closed. */
|
|
18
18
|
readonly closeTimeout?: number;
|
|
19
19
|
/** Maximum allowed size, in bytes, of a single WebSocket message. */
|
|
@@ -26,14 +26,14 @@ interface NodeWebSocketOptions {
|
|
|
26
26
|
readonly allowedOrigins?: readonly string[];
|
|
27
27
|
}
|
|
28
28
|
/** Options shared by anything that turns Node HTTP requests into `@askrjs/server` fetch calls. */
|
|
29
|
-
interface NodeHandlerOptions {
|
|
29
|
+
export interface NodeHandlerOptions {
|
|
30
30
|
/** Base URL used to resolve request paths into absolute URLs. */
|
|
31
31
|
readonly baseUrl?: string;
|
|
32
32
|
/** Hosts allowed in the request's `Host` header; requests for other hosts are rejected. */
|
|
33
33
|
readonly allowedHosts?: readonly string[];
|
|
34
34
|
}
|
|
35
35
|
/** Options for {@link listen}, controlling how the Node HTTP server binds and behaves. */
|
|
36
|
-
interface ListenOptions extends NodeHandlerOptions {
|
|
36
|
+
export interface ListenOptions extends NodeHandlerOptions {
|
|
37
37
|
/** Port to listen on; defaults to an ephemeral port when omitted. */
|
|
38
38
|
port?: number;
|
|
39
39
|
/** Host/address to bind to. */
|
|
@@ -54,7 +54,7 @@ interface ListenOptions extends NodeHandlerOptions {
|
|
|
54
54
|
websocket?: boolean | NodeWebSocketOptions;
|
|
55
55
|
}
|
|
56
56
|
/** Options for {@link serve}, extending {@link ListenOptions} with static asset serving and shutdown behavior. */
|
|
57
|
-
interface ServeOptions extends ListenOptions {
|
|
57
|
+
export interface ServeOptions extends ListenOptions {
|
|
58
58
|
/** Serves static files from this directory before falling back to the application. */
|
|
59
59
|
readonly assets?: {
|
|
60
60
|
readonly root: string;
|
|
@@ -65,7 +65,7 @@ interface ServeOptions extends ListenOptions {
|
|
|
65
65
|
readonly signals?: false | readonly NodeJS.Signals[];
|
|
66
66
|
}
|
|
67
67
|
/** A running application returned by {@link serve}. */
|
|
68
|
-
interface ServedApplication {
|
|
68
|
+
export interface ServedApplication {
|
|
69
69
|
/** The underlying Node HTTP server. */
|
|
70
70
|
readonly server: import("node:http").Server;
|
|
71
71
|
/** The base URL the server is listening on. */
|
|
@@ -74,9 +74,9 @@ interface ServedApplication {
|
|
|
74
74
|
close(): Promise<void>;
|
|
75
75
|
}
|
|
76
76
|
/** Connect/Express-style `next` callback used to hand off unhandled requests. */
|
|
77
|
-
type ConnectNext = (error?: unknown) => void;
|
|
77
|
+
export type ConnectNext = (error?: unknown) => void;
|
|
78
78
|
/** A Node-style request handler compatible with `http.Server` and Connect-style middleware chains. */
|
|
79
|
-
type NodeHandler = (request: IncomingMessage, response: ServerResponse, next?: ConnectNext) => void;
|
|
79
|
+
export type NodeHandler = (request: IncomingMessage, response: ServerResponse, next?: ConnectNext) => void;
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/handler.d.ts
|
|
82
82
|
/**
|
|
@@ -91,11 +91,11 @@ type NodeHandler = (request: IncomingMessage, response: ServerResponse, next?: C
|
|
|
91
91
|
* @param options - Options controlling base URL resolution and host validation.
|
|
92
92
|
* @returns A handler usable with `http.createServer` or Connect-style middleware.
|
|
93
93
|
*/
|
|
94
|
-
declare function createNodeHandler(app: ServerApp, options: NodeHandlerOptions): NodeHandler;
|
|
94
|
+
export declare function createNodeHandler(app: ServerApp, options: NodeHandlerOptions): NodeHandler;
|
|
95
95
|
//#endregion
|
|
96
96
|
//#region src/listen.d.ts
|
|
97
97
|
/** A Node HTTP server that is guaranteed to be listening for connections. */
|
|
98
|
-
type ListeningServer = Server & {
|
|
98
|
+
export type ListeningServer = Server & {
|
|
99
99
|
address(): AddressInfo | string | null;
|
|
100
100
|
};
|
|
101
101
|
/**
|
|
@@ -111,7 +111,7 @@ type ListeningServer = Server & {
|
|
|
111
111
|
* @example
|
|
112
112
|
* const server = await listen(app, { port: 3000 });
|
|
113
113
|
*/
|
|
114
|
-
declare function listen(app: ServerApp, options?: ListenOptions): Promise<ListeningServer>;
|
|
114
|
+
export declare function listen(app: ServerApp, options?: ListenOptions): Promise<ListeningServer>;
|
|
115
115
|
//#endregion
|
|
116
116
|
//#region src/serve.d.ts
|
|
117
117
|
/**
|
|
@@ -134,8 +134,7 @@ declare function listen(app: ServerApp, options?: ListenOptions): Promise<Listen
|
|
|
134
134
|
* // ...
|
|
135
135
|
* await app.close();
|
|
136
136
|
*/
|
|
137
|
-
declare function serve(app: ServerApp & {
|
|
137
|
+
export declare function serve(app: ServerApp & {
|
|
138
138
|
close?: () => void | Promise<void>;
|
|
139
139
|
}, options?: ServeOptions): Promise<ServedApplication>;
|
|
140
|
-
//#endregion
|
|
141
|
-
export { CLIENT_ADDRESS_HEADER, ConnectNext, ListenOptions, ListeningServer, NodeHandler, NodeHandlerOptions, NodeWebSocketOptions, ServeOptions, ServedApplication, createNodeHandler, listen, normalizeClientAddress, serve };
|
|
140
|
+
//#endregion
|
package/dist/mcp.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { AuthContext } from "@askrjs/auth";
|
|
|
3
3
|
import { McpServer } from "@askrjs/server/mcp";
|
|
4
4
|
//#region src/mcp.d.ts
|
|
5
5
|
/** Options for {@link connectMcpStdio}. */
|
|
6
|
-
interface McpStdioOptions<Dependencies = undefined> {
|
|
6
|
+
export interface McpStdioOptions<Dependencies = undefined> {
|
|
7
7
|
/** Application dependencies passed through to each MCP request. */
|
|
8
8
|
dependencies: Dependencies;
|
|
9
9
|
/** Stream to read newline-delimited JSON-RPC requests from; defaults to `process.stdin`. */
|
|
@@ -24,7 +24,7 @@ interface McpStdioOptions<Dependencies = undefined> {
|
|
|
24
24
|
maxConcurrency?: number;
|
|
25
25
|
}
|
|
26
26
|
/** A live MCP stdio connection returned by {@link connectMcpStdio}. */
|
|
27
|
-
interface McpStdioConnection {
|
|
27
|
+
export interface McpStdioConnection {
|
|
28
28
|
/** Resolves once the connection has fully closed. */
|
|
29
29
|
readonly closed: Promise<void>;
|
|
30
30
|
/** Closes the connection, aborting in-flight requests and terminating the MCP session. */
|
|
@@ -43,6 +43,5 @@ interface McpStdioConnection {
|
|
|
43
43
|
* @param options - Stdio connection options, including dependencies and stream overrides.
|
|
44
44
|
* @returns A handle exposing `closed` and `close()` for the connection's lifecycle.
|
|
45
45
|
*/
|
|
46
|
-
declare function connectMcpStdio<Dependencies>(mcp: McpServer<Dependencies>, options: McpStdioOptions<Dependencies>): McpStdioConnection;
|
|
47
|
-
//#endregion
|
|
48
|
-
export { McpStdioConnection, McpStdioOptions, connectMcpStdio };
|
|
46
|
+
export declare function connectMcpStdio<Dependencies>(mcp: McpServer<Dependencies>, options: McpStdioOptions<Dependencies>): McpStdioConnection;
|
|
47
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askrjs/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Node http adapter for @askrjs/server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"askr",
|
|
@@ -57,17 +57,17 @@
|
|
|
57
57
|
"prepublishOnly": "npm run check"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@askrjs/auth": ">=0.
|
|
61
|
-
"@askrjs/server": ">=0.
|
|
60
|
+
"@askrjs/auth": ">=0.3.0 <0.4.0",
|
|
61
|
+
"@askrjs/server": ">=0.3.0 <0.4.0",
|
|
62
62
|
"@types/ws": "^8.18.1",
|
|
63
63
|
"ws": "^8.21.3"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@askrjs/schema": ">=0.
|
|
66
|
+
"@askrjs/schema": ">=0.3.0 <0.4.0",
|
|
67
67
|
"@types/node": "^26.3.0",
|
|
68
68
|
"publint": "^0.3.24",
|
|
69
69
|
"typescript": "^7.0.2",
|
|
70
|
-
"vite-plus": "^0.3.
|
|
70
|
+
"vite-plus": "^0.3.1",
|
|
71
71
|
"vitest": "^4.1.11"
|
|
72
72
|
},
|
|
73
73
|
"engines": {
|