@orpc/standard-server-node 0.45.0 → 0.46.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.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { StandardBody, StandardHeaders, StandardRequest, StandardResponse } from '@orpc/standard-server';
1
+ import { StandardBody, StandardHeaders, StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
2
2
  import { Readable } from 'node:stream';
3
3
  import { IncomingMessage, ServerResponse } from 'node:http';
4
4
  import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
@@ -10,21 +10,21 @@ interface ToEventStreamOptions {
10
10
  *
11
11
  * @default true
12
12
  */
13
- eventSourcePingEnabled?: boolean;
13
+ eventIteratorKeepAliveEnabled?: boolean;
14
14
  /**
15
15
  * Interval (in milliseconds) between ping comments sent after the last event.
16
16
  *
17
17
  * @default 5000
18
18
  */
19
- eventSourcePingInterval?: number;
19
+ eventIteratorKeepAliveInterval?: number;
20
20
  /**
21
21
  * The content of the ping comment. Must not include newline characters.
22
22
  *
23
23
  * @default ''
24
24
  */
25
- eventSourcePingContent?: string;
25
+ eventIteratorKeepAliveComment?: string;
26
26
  }
27
- declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options?: ToEventStreamOptions): Readable;
27
+ declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options: ToEventStreamOptions): Readable;
28
28
 
29
29
  type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
30
30
  /**
@@ -43,14 +43,14 @@ interface ToNodeHttpBodyOptions extends ToEventStreamOptions {
43
43
  * @param headers - WARNING: The headers can be changed by the function and effects on the original headers.
44
44
  * @param options
45
45
  */
46
- declare function toNodeHttpBody(body: StandardBody, headers: StandardHeaders, options?: ToNodeHttpBodyOptions): Readable | undefined | string;
46
+ declare function toNodeHttpBody(body: StandardBody, headers: StandardHeaders, options: ToNodeHttpBodyOptions): Readable | undefined | string;
47
47
 
48
- declare function toStandardRequest(req: NodeHttpRequest, res: NodeHttpResponse): StandardRequest;
48
+ declare function toStandardLazyRequest(req: NodeHttpRequest, res: NodeHttpResponse): StandardLazyRequest;
49
49
 
50
50
  interface SendStandardResponseOptions extends ToNodeHttpBodyOptions {
51
51
  }
52
- declare function sendStandardResponse(res: NodeHttpResponse, standardResponse: StandardResponse, options?: SendStandardResponseOptions): Promise<void>;
52
+ declare function sendStandardResponse(res: NodeHttpResponse, standardResponse: StandardResponse, options: SendStandardResponseOptions): Promise<void>;
53
53
 
54
54
  declare function toAbortSignal(res: NodeHttpResponse): AbortSignal;
55
55
 
56
- export { type NodeHttpRequest, type NodeHttpResponse, type SendStandardResponseOptions, type ToEventStreamOptions, type ToNodeHttpBodyOptions, sendStandardResponse, toAbortSignal, toEventIterator, toEventStream, toNodeHttpBody, toStandardBody, toStandardRequest };
56
+ export { type NodeHttpRequest, type NodeHttpResponse, type SendStandardResponseOptions, type ToEventStreamOptions, type ToNodeHttpBodyOptions, sendStandardResponse, toAbortSignal, toEventIterator, toEventStream, toNodeHttpBody, toStandardBody, toStandardLazyRequest };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { StandardBody, StandardHeaders, StandardRequest, StandardResponse } from '@orpc/standard-server';
1
+ import { StandardBody, StandardHeaders, StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
2
2
  import { Readable } from 'node:stream';
3
3
  import { IncomingMessage, ServerResponse } from 'node:http';
4
4
  import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
@@ -10,21 +10,21 @@ interface ToEventStreamOptions {
10
10
  *
11
11
  * @default true
12
12
  */
13
- eventSourcePingEnabled?: boolean;
13
+ eventIteratorKeepAliveEnabled?: boolean;
14
14
  /**
15
15
  * Interval (in milliseconds) between ping comments sent after the last event.
16
16
  *
17
17
  * @default 5000
18
18
  */
19
- eventSourcePingInterval?: number;
19
+ eventIteratorKeepAliveInterval?: number;
20
20
  /**
21
21
  * The content of the ping comment. Must not include newline characters.
22
22
  *
23
23
  * @default ''
24
24
  */
25
- eventSourcePingContent?: string;
25
+ eventIteratorKeepAliveComment?: string;
26
26
  }
27
- declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options?: ToEventStreamOptions): Readable;
27
+ declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>, options: ToEventStreamOptions): Readable;
28
28
 
29
29
  type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
30
30
  /**
@@ -43,14 +43,14 @@ interface ToNodeHttpBodyOptions extends ToEventStreamOptions {
43
43
  * @param headers - WARNING: The headers can be changed by the function and effects on the original headers.
44
44
  * @param options
45
45
  */
46
- declare function toNodeHttpBody(body: StandardBody, headers: StandardHeaders, options?: ToNodeHttpBodyOptions): Readable | undefined | string;
46
+ declare function toNodeHttpBody(body: StandardBody, headers: StandardHeaders, options: ToNodeHttpBodyOptions): Readable | undefined | string;
47
47
 
48
- declare function toStandardRequest(req: NodeHttpRequest, res: NodeHttpResponse): StandardRequest;
48
+ declare function toStandardLazyRequest(req: NodeHttpRequest, res: NodeHttpResponse): StandardLazyRequest;
49
49
 
50
50
  interface SendStandardResponseOptions extends ToNodeHttpBodyOptions {
51
51
  }
52
- declare function sendStandardResponse(res: NodeHttpResponse, standardResponse: StandardResponse, options?: SendStandardResponseOptions): Promise<void>;
52
+ declare function sendStandardResponse(res: NodeHttpResponse, standardResponse: StandardResponse, options: SendStandardResponseOptions): Promise<void>;
53
53
 
54
54
  declare function toAbortSignal(res: NodeHttpResponse): AbortSignal;
55
55
 
56
- export { type NodeHttpRequest, type NodeHttpResponse, type SendStandardResponseOptions, type ToEventStreamOptions, type ToNodeHttpBodyOptions, sendStandardResponse, toAbortSignal, toEventIterator, toEventStream, toNodeHttpBody, toStandardBody, toStandardRequest };
56
+ export { type NodeHttpRequest, type NodeHttpResponse, type SendStandardResponseOptions, type ToEventStreamOptions, type ToNodeHttpBodyOptions, sendStandardResponse, toAbortSignal, toEventIterator, toEventStream, toNodeHttpBody, toStandardBody, toStandardLazyRequest };
package/dist/index.mjs CHANGED
@@ -43,20 +43,20 @@ function toEventIterator(stream) {
43
43
  }
44
44
  return gen();
45
45
  }
46
- function toEventStream(iterator, options = {}) {
47
- const pingEnabled = options.eventSourcePingEnabled ?? true;
48
- const pingInterval = options.eventSourcePingInterval ?? 5e3;
49
- const pingContent = options.eventSourcePingContent ?? "";
46
+ function toEventStream(iterator, options) {
47
+ const keepAliveEnabled = options.eventIteratorKeepAliveEnabled ?? true;
48
+ const keepAliveInterval = options.eventIteratorKeepAliveInterval ?? 5e3;
49
+ const keepAliveComment = options.eventIteratorKeepAliveComment ?? "";
50
50
  let timeout;
51
51
  const stream = new ReadableStream({
52
52
  async pull(controller) {
53
53
  try {
54
- if (pingEnabled) {
54
+ if (keepAliveEnabled) {
55
55
  timeout = setInterval(() => {
56
56
  controller.enqueue(encodeEventMessage({
57
- comments: [pingContent]
57
+ comments: [keepAliveComment]
58
58
  }));
59
- }, pingInterval);
59
+ }, keepAliveInterval);
60
60
  }
61
61
  const value = await iterator.next();
62
62
  clearInterval(timeout);
@@ -121,7 +121,7 @@ async function toStandardBody(req) {
121
121
  }
122
122
  return _streamToFile(req, "blob", contentType);
123
123
  }
124
- function toNodeHttpBody(body, headers, options = {}) {
124
+ function toNodeHttpBody(body, headers, options) {
125
125
  delete headers["content-type"];
126
126
  delete headers["content-disposition"];
127
127
  if (body === void 0) {
@@ -191,7 +191,7 @@ function toAbortSignal(res) {
191
191
  return controller.signal;
192
192
  }
193
193
 
194
- function toStandardRequest(req, res) {
194
+ function toStandardLazyRequest(req, res) {
195
195
  const method = req.method ?? "GET";
196
196
  const protocol = "encrypted" in req.socket && req.socket.encrypted ? "https:" : "http:";
197
197
  const host = req.headers.host ?? "localhost";
@@ -206,7 +206,7 @@ function toStandardRequest(req, res) {
206
206
  };
207
207
  }
208
208
 
209
- function sendStandardResponse(res, standardResponse, options = {}) {
209
+ function sendStandardResponse(res, standardResponse, options) {
210
210
  return new Promise((resolve, reject) => {
211
211
  res.on("error", reject);
212
212
  res.on("finish", resolve);
@@ -228,4 +228,4 @@ function sendStandardResponse(res, standardResponse, options = {}) {
228
228
  });
229
229
  }
230
230
 
231
- export { sendStandardResponse, toAbortSignal, toEventIterator, toEventStream, toNodeHttpBody, toStandardBody, toStandardRequest };
231
+ export { sendStandardResponse, toAbortSignal, toEventIterator, toEventStream, toNodeHttpBody, toStandardBody, toStandardLazyRequest };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/standard-server-node",
3
3
  "type": "module",
4
- "version": "0.45.0",
4
+ "version": "0.46.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -23,8 +23,8 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@orpc/shared": "0.45.0",
27
- "@orpc/standard-server": "0.45.0"
26
+ "@orpc/shared": "0.46.0",
27
+ "@orpc/standard-server": "0.46.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "^22.13.1",