Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): preserve compressed asset content types #11768

ClosedPastequee(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/11768/headopened View on GitHub

Showing 2 changed files with 52 additions and 1 deletion.

x
0 of 2 viewed, 2 left
32 additions and 0 deletionsapps/server/src/http.test.tsModified
View file
@@ -1,11 +1,15 @@
import { expect, it } from "@effect/vitest";
import { describe, vi } from "vite-plus/test";
import * as NodeHttpPlatform from "@effect/platform-node/NodeHttpPlatform";
+import * as NodeHttpServer from "@effect/platform-node/NodeHttpServer";
import * as NodeServices from "@effect/platform-node/NodeServices";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
import * as Path from "effect/Path";
+import * as HttpClient from "effect/unstable/http/HttpClient";
+import * as HttpMiddleware from "effect/unstable/http/HttpMiddleware";
+import * as HttpRouter from "effect/unstable/http/HttpRouter";
import { HttpServerResponse } from "effect/unstable/http";
import { openMediaFile } from "./assets/MediaFile.ts";
​
@@ -19,6 +23,34 @@
​
const fileResponseLayer = Layer.mergeAll(NodeHttpPlatform.layer, NodeServices.layer);
​
+describe("asset compression", () => {
+ it.effect("preserves the content type of compressed HTML files", () =>
+ Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const directory = yield* fs.makeTempDirectoryScoped({ prefix: "t3-compressed-asset-" });
+ const filePath = path.join(directory, "index.html");
+ const contents = `<!doctype html><title>Preview</title><p>${"content".repeat(512)}</p>`;
+ yield* fs.writeFileString(filePath, contents);
+​