@askrjs/node 0.0.2 → 0.0.4

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/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # @askrjs/node
2
+
3
+ [![CI](https://github.com/askrjs/askr-node/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/askrjs/askr-node/actions/workflows/ci.yml)
4
+ [![npm version](https://img.shields.io/npm/v/%40askrjs%2Fnode.svg)](https://www.npmjs.com/package/@askrjs/node)
5
+
6
+ Run an `@askrjs/server` application on Node.js. The adapter translates Node HTTP messages at the
7
+ boundary while the application continues to use Web `Request` and `Response` objects.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install @askrjs/server @askrjs/node
13
+ ```
14
+
15
+ ## Create a Node handler
16
+
17
+ ```ts
18
+ import { createServer } from "node:http";
19
+ import { createServerApp, json } from "@askrjs/server";
20
+ import { createNodeHandler } from "@askrjs/node";
21
+
22
+ const app = createServerApp({
23
+ routes: [{ path: "/health", handler: () => json({ status: "ok" }) }],
24
+ });
25
+
26
+ createServer(createNodeHandler(app)).listen(3000);
27
+ ```
28
+
29
+ `createNodeHandler` also works as Connect middleware because it accepts an optional `next`
30
+ callback. It preserves streaming bodies, repeated `Set-Cookie` headers, aborts, backpressure,
31
+ status text, and HEAD responses.
32
+
33
+ ## Listen directly
34
+
35
+ ```ts
36
+ import { listen } from "@askrjs/node";
37
+
38
+ const server = await listen(app, { port: 3000 });
39
+ server.close();
40
+ ```
41
+
42
+ Pass an `AbortSignal` to integrate shutdown with your process lifecycle.
43
+
44
+ ## Serve a production application
45
+
46
+ ```ts
47
+ import { serve } from "@askrjs/node";
48
+
49
+ const running = await serve(app, {
50
+ port: 3000,
51
+ assets: { root: "./dist/client" },
52
+ });
53
+
54
+ await running.close();
55
+ ```
56
+
57
+ `serve` handles static assets and closes both the HTTP server and the application during shutdown.
58
+
59
+ ## MCP over stdio
60
+
61
+ ```ts
62
+ import { connectMcpStdio } from "@askrjs/node/mcp";
63
+
64
+ const connection = connectMcpStdio(mcp, { dependencies });
65
+ await connection.closed;
66
+ ```
67
+
68
+ Protocol messages use stdin/stdout; diagnostics remain isolated on stderr. Authentication may be
69
+ provided directly or resolved from the process environment for each message.
package/dist/index.d.ts CHANGED
@@ -39,5 +39,4 @@ declare function serve(app: ServerApp & {
39
39
  close?: () => void | Promise<void>;
40
40
  }, options?: ServeOptions): Promise<ServedApplication>;
41
41
  //#endregion
42
- export { ConnectNext, ListenOptions, ListeningServer, NodeHandler, NodeHandlerOptions, ServeOptions, ServedApplication, createNodeHandler, listen, serve };
43
- //# sourceMappingURL=index.d.ts.map
42
+ export { ConnectNext, ListenOptions, ListeningServer, NodeHandler, NodeHandlerOptions, ServeOptions, ServedApplication, createNodeHandler, listen, serve };
package/dist/index.js CHANGED
@@ -267,5 +267,3 @@ async function serve(app, options = {}) {
267
267
  }
268
268
  //#endregion
269
269
  export { createNodeHandler, listen, serve };
270
-
271
- //# sourceMappingURL=index.js.map
package/dist/mcp.d.ts CHANGED
@@ -17,5 +17,4 @@ interface McpStdioConnection {
17
17
  }
18
18
  declare function connectMcpStdio<Dependencies>(mcp: McpServer<Dependencies>, options: McpStdioOptions<Dependencies>): McpStdioConnection;
19
19
  //#endregion
20
- export { McpStdioConnection, McpStdioOptions, connectMcpStdio };
21
- //# sourceMappingURL=mcp.d.ts.map
20
+ export { McpStdioConnection, McpStdioOptions, connectMcpStdio };
package/dist/mcp.js CHANGED
@@ -93,5 +93,3 @@ function connectMcpStdio(mcp, options) {
93
93
  }
94
94
  //#endregion
95
95
  export { connectMcpStdio };
96
-
97
- //# sourceMappingURL=mcp.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askrjs/node",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Node http adapter for @askrjs/server",
5
5
  "keywords": [
6
6
  "askr",
@@ -49,7 +49,7 @@
49
49
  "typecheck": "tsc -p tsconfig.json --noEmit",
50
50
  "test": "vp test run",
51
51
  "test:publint": "publint",
52
- "pack:check": "npm pack --ignore-scripts --dry-run --json",
52
+ "pack:check": "node tests/package-artifacts.js",
53
53
  "check": "npm run lint && npm run typecheck && npm test && npm run build && npm run test:publint && npm run pack:check",
54
54
  "prepack": "npm run build",
55
55
  "prepublishOnly": "npm run check"