@orpc/standard-server-fetch 0.0.0-next.cd121e3 → 0.0.0-next.d16a1b6
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 +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +27 -2
- package/package.json +3 -3
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, StandardRequest, StandardResponse, StandardLazyResponse } from '@orpc/standard-server';
|
|
2
2
|
|
|
3
3
|
declare function toEventIterator(stream: ReadableStream<Uint8Array>): AsyncGenerator<unknown | void, unknown | void, void>;
|
|
4
4
|
interface ToEventStreamOptions {
|
|
@@ -43,10 +43,12 @@ declare function toStandardHeaders(headers: Headers, standardHeaders?: StandardH
|
|
|
43
43
|
*/
|
|
44
44
|
declare function toFetchHeaders(headers: StandardHeaders, fetchHeaders?: Headers): Headers;
|
|
45
45
|
|
|
46
|
-
declare function
|
|
46
|
+
declare function toStandardLazyRequest(request: Request): StandardLazyRequest;
|
|
47
|
+
declare function toFetchRequest(request: StandardRequest): Request;
|
|
47
48
|
|
|
48
49
|
interface ToFetchResponseOptions extends ToFetchBodyOptions {
|
|
49
50
|
}
|
|
50
51
|
declare function toFetchResponse(response: StandardResponse, options?: ToFetchResponseOptions): Response;
|
|
52
|
+
declare function toStandardLazyResponse(response: Response): StandardLazyResponse;
|
|
51
53
|
|
|
52
|
-
export { type ToEventStreamOptions, type ToFetchBodyOptions, type ToFetchResponseOptions, toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchResponse, toStandardBody, toStandardHeaders,
|
|
54
|
+
export { type ToEventStreamOptions, type ToFetchBodyOptions, type ToFetchResponseOptions, toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchRequest, toFetchResponse, toStandardBody, toStandardHeaders, toStandardLazyRequest, toStandardLazyResponse };
|
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, StandardRequest, StandardResponse, StandardLazyResponse } from '@orpc/standard-server';
|
|
2
2
|
|
|
3
3
|
declare function toEventIterator(stream: ReadableStream<Uint8Array>): AsyncGenerator<unknown | void, unknown | void, void>;
|
|
4
4
|
interface ToEventStreamOptions {
|
|
@@ -43,10 +43,12 @@ declare function toStandardHeaders(headers: Headers, standardHeaders?: StandardH
|
|
|
43
43
|
*/
|
|
44
44
|
declare function toFetchHeaders(headers: StandardHeaders, fetchHeaders?: Headers): Headers;
|
|
45
45
|
|
|
46
|
-
declare function
|
|
46
|
+
declare function toStandardLazyRequest(request: Request): StandardLazyRequest;
|
|
47
|
+
declare function toFetchRequest(request: StandardRequest): Request;
|
|
47
48
|
|
|
48
49
|
interface ToFetchResponseOptions extends ToFetchBodyOptions {
|
|
49
50
|
}
|
|
50
51
|
declare function toFetchResponse(response: StandardResponse, options?: ToFetchResponseOptions): Response;
|
|
52
|
+
declare function toStandardLazyResponse(response: Response): StandardLazyResponse;
|
|
51
53
|
|
|
52
|
-
export { type ToEventStreamOptions, type ToFetchBodyOptions, type ToFetchResponseOptions, toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchResponse, toStandardBody, toStandardHeaders,
|
|
54
|
+
export { type ToEventStreamOptions, type ToFetchBodyOptions, type ToFetchResponseOptions, toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchRequest, toFetchResponse, toStandardBody, toStandardHeaders, toStandardLazyRequest, toStandardLazyResponse };
|
package/dist/index.mjs
CHANGED
|
@@ -181,7 +181,7 @@ function toFetchHeaders(headers, fetchHeaders = new Headers()) {
|
|
|
181
181
|
return fetchHeaders;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
function
|
|
184
|
+
function toStandardLazyRequest(request) {
|
|
185
185
|
return {
|
|
186
186
|
raw: { request },
|
|
187
187
|
url: new URL(request.url),
|
|
@@ -198,11 +198,36 @@ function toStandardRequest(request) {
|
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
+
function toFetchRequest(request) {
|
|
202
|
+
const headers = toFetchHeaders(request.headers);
|
|
203
|
+
const body = toFetchBody(request.body, headers);
|
|
204
|
+
return new Request(request.url, {
|
|
205
|
+
signal: request.signal,
|
|
206
|
+
method: request.method,
|
|
207
|
+
headers,
|
|
208
|
+
body
|
|
209
|
+
});
|
|
210
|
+
}
|
|
201
211
|
|
|
202
212
|
function toFetchResponse(response, options = {}) {
|
|
203
213
|
const headers = toFetchHeaders(response.headers);
|
|
204
214
|
const body = toFetchBody(response.body, headers, options);
|
|
205
215
|
return new Response(body, { headers, status: response.status });
|
|
206
216
|
}
|
|
217
|
+
function toStandardLazyResponse(response) {
|
|
218
|
+
return {
|
|
219
|
+
raw: { response },
|
|
220
|
+
body: once(() => toStandardBody(response)),
|
|
221
|
+
status: response.status,
|
|
222
|
+
get headers() {
|
|
223
|
+
const headers = toStandardHeaders(response.headers);
|
|
224
|
+
Object.defineProperty(this, "headers", { value: headers, writable: true });
|
|
225
|
+
return headers;
|
|
226
|
+
},
|
|
227
|
+
set headers(value) {
|
|
228
|
+
Object.defineProperty(this, "headers", { value, writable: true });
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
207
232
|
|
|
208
|
-
export { toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchResponse, toStandardBody, toStandardHeaders,
|
|
233
|
+
export { toEventIterator, toEventStream, toFetchBody, toFetchHeaders, toFetchRequest, toFetchResponse, toStandardBody, toStandardHeaders, toStandardLazyRequest, toStandardLazyResponse };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/standard-server-fetch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.d16a1b6",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@orpc/shared": "0.0.0-next.
|
|
27
|
-
"@orpc/standard-server": "0.0.0-next.
|
|
26
|
+
"@orpc/shared": "0.0.0-next.d16a1b6",
|
|
27
|
+
"@orpc/standard-server": "0.0.0-next.d16a1b6"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@hono/node-server": "^1.13.8"
|