Qualify kind of stream

This commit is contained in:
Cadence Ember
2025-02-16 17:44:17 +13:00
parent 0d0ca98e13
commit a5fd30d535
11 changed files with 26 additions and 25 deletions

View File

@@ -1,5 +1,6 @@
// @ts-check
const assert = require("assert")
const fs = require("fs")
const {join} = require("path")
const h3 = require("h3")
@@ -38,8 +39,8 @@ function compressResponse(event, response) {
if (!getRequestHeader(event, "accept-encoding")?.includes("gzip")) return
/* c8 ignore next */
if (typeof response.body !== "string") return
/** @type {ReadableStream} */ // @ts-ignore
const stream = new Response(response.body).body
assert(stream)
setResponseHeader(event, "content-encoding", "gzip")
response.body = stream.pipeThrough(new CompressionStream("gzip"))
}