fix high compression

This commit is contained in:
Rizky 2024-06-28 01:03:55 +07:00
parent 212a426f59
commit 15afba33f1
1 changed files with 11 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { apiContext } from "service-srv"; import { apiContext, createResponse } from "service-srv";
import { SinglePage, g } from "utils/global"; import { SinglePage, g } from "utils/global";
import { gzipAsync } from "utils/gzip"; import { gzipAsync } from "utils/gzip";
import { getContent } from "../server/prep-api-ts"; import { getContent } from "../server/prep-api-ts";
@ -61,13 +61,16 @@ export const _ = {
page: async () => { page: async () => {
const page = g.deploy.pages[parts[1]]; const page = g.deploy.pages[parts[1]];
if (page) { if (page) {
return await responseCompressed( return createResponse(
req,
JSON.stringify({ JSON.stringify({
id: page.id, id: page.id,
root: page.content_tree, root: page.content_tree,
url: page.url, url: page.url,
}) }),
{
cache_accept: req.headers.get("accept-encoding") || "",
high_compression: true,
}
); );
} }
}, },
@ -118,7 +121,10 @@ export const _ = {
} catch (e) {} } catch (e) {}
} }
return await responseCompressed(req, JSON.stringify(comps)); return createResponse(JSON.stringify(comps), {
cache_accept: req.headers.get("accept-encoding") || "",
high_compression: true,
});
}, },
"load.json": async () => { "load.json": async () => {
res.setHeader("content-type", "application/json"); res.setHeader("content-type", "application/json");