Initial work on upload app server

This commit is contained in:
Alan Grainger
2026-10-06 10:07:20 +13:00
parent 9e6c00da35
commit 95ac498cf0
38 changed files with 1493 additions and 40 deletions
+16
View File
@@ -12,3 +12,19 @@ export function readableFromWeb (body: ReadableStream<Uint8Array>): Readable {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return Readable.fromWeb(body as any)
}
/**
* Build a `fetch` init that streams `body` as the request body.
*
* Node's fetch refuses a stream body unless `duplex: 'half'` is set, but that
* option is absent from the DOM `RequestInit` the project's `lib` resolves
* to, so it has to go on behind a cast.
*/
export function streamingRequestInit (init: RequestInit, body: Readable): RequestInit {
return {
...init,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
body: Readable.toWeb(body) as any,
duplex: 'half'
} as RequestInit
}