import type { IHttpServerComponent } from '@dcl/core-commons'; /** * Adapts a native `Response` (e.g. one obtained from `fetch`) into the server's * `IResponse` shape so it can be returned from a handler and flow safely through * the middleware pipeline. * * The pipeline carries the structural `IResponse` (Node `Readable`/`Buffer` bodies). * A native `Response` has a web `ReadableStream` body and is *not* assignable to * `IResponse`; forcing one in via `as any` lets response-transforming middleware * corrupt it — e.g. CORS does `{ ...response }`, and a `Response`'s `status`/`body` * are prototype getters, so the spread drops them (served as a bodiless `200`). * Convert at the boundary instead: * * ```ts * router.get('/proxy', async () => fromNativeResponse(await fetch(upstreamUrl))) * ``` * * The body is streamed (via `Readable.fromWeb`), not buffered, so proxying large * responses stays memory-safe. The passed `Response`'s body is taken over by the * returned stream — don't also read it with `.text()`/`.json()`. * * @public */ export declare function fromNativeResponse(response: Response): IHttpServerComponent.IResponse;