From c33e081841ee7af9d791c4ae4cb72ed30355fc25 Mon Sep 17 00:00:00 2001 From: Rizky Date: Thu, 8 Aug 2024 14:45:18 +0700 Subject: [PATCH] fix --- pkgs/api/_zip.ts | 5 +++-- pkgs/server/api-ctx.ts | 1 + pkgs/server/serve-web.ts | 2 +- pkgs/utils/deploy.ts | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/api/_zip.ts b/pkgs/api/_zip.ts index 0d1f5b9..22b6c9c 100644 --- a/pkgs/api/_zip.ts +++ b/pkgs/api/_zip.ts @@ -1,6 +1,6 @@ import { $ } from "bun"; import Database from "bun:sqlite"; -import { copyAsync, removeAsync } from "fs-jetpack"; +import { copyAsync } from "fs-jetpack"; import mime from "mime"; import { deploy } from "utils/deploy"; import { dir } from "utils/dir"; @@ -50,6 +50,7 @@ export const _ = { content: g.deploy.content?.site?.config?.api_url || "", }); const gz = g.deploy.content; + if (gz) { let layout = null as null | SinglePage; for (const l of gz.layouts) { @@ -80,7 +81,7 @@ export const _ = { add({ path: "load-js", type: "", - content: await getContent("load.js.prod", api_url), + content: await getContent("load.js.prod", `"${api_url}"`), }); } diff --git a/pkgs/server/api-ctx.ts b/pkgs/server/api-ctx.ts index 9da260c..8f7ac73 100644 --- a/pkgs/server/api-ctx.ts +++ b/pkgs/server/api-ctx.ts @@ -73,6 +73,7 @@ export const createResponse = ( if (opt?.cache_accept) { let cached = false; + if ( opt?.high_compression && opt.cache_accept.toLowerCase().includes("br") diff --git a/pkgs/server/serve-web.ts b/pkgs/server/serve-web.ts index 9775808..0fcb420 100644 --- a/pkgs/server/serve-web.ts +++ b/pkgs/server/serve-web.ts @@ -10,7 +10,7 @@ export const serveWeb = async (arg: { return createResponse(arg.content, { cache_accept: arg.cache_accept, - high_compression: false, + high_compression: true, headers: !type ? undefined : { "content-type": type }, }); }; diff --git a/pkgs/utils/deploy.ts b/pkgs/utils/deploy.ts index 5bc20bd..dc481f3 100644 --- a/pkgs/utils/deploy.ts +++ b/pkgs/utils/deploy.ts @@ -143,7 +143,7 @@ export const deploy = { } console.log( - `Downloading site deploy: ${this.config.site_id} [ts: ${this.config.deploy.ts}]` + `Downloading site deploy: ${this.config.site_id} [ts: ${this.config.deploy.ts}] ${base_url}` ); const res = await fetch( `${base_url}/prod-zip/${this.config.site_id}?ts=${Date.now()}&msgpack=1`