wip fix
This commit is contained in:
parent
81fa96ec5b
commit
af4b8110f6
|
|
@ -42,7 +42,8 @@ export const _ = {
|
||||||
if (l.is_default_layout) layout = l;
|
if (l.is_default_layout) layout = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await gzipAsync(
|
return await responseCompressed(
|
||||||
|
req,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
site: { ...gz.site, api_url: (gz.site as any)?.config?.api_url },
|
site: { ...gz.site, api_url: (gz.site as any)?.config?.api_url },
|
||||||
urls: gz.pages.map((e) => {
|
urls: gz.pages.map((e) => {
|
||||||
|
|
@ -50,26 +51,23 @@ export const _ = {
|
||||||
}),
|
}),
|
||||||
layout: {
|
layout: {
|
||||||
id: layout?.id,
|
id: layout?.id,
|
||||||
root: layout?.content_tree
|
root: layout?.content_tree,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response(result, { headers: res.headers });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
page: async () => {
|
page: async () => {
|
||||||
const page = g.deploy.pages[parts[1]];
|
const page = g.deploy.pages[parts[1]];
|
||||||
if (page) {
|
if (page) {
|
||||||
const result = await gzipAsync(
|
return await responseCompressed(
|
||||||
|
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,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response(result, { headers: res.headers });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pages: async () => {
|
pages: async () => {
|
||||||
|
|
@ -87,9 +85,7 @@ export const _ = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response(await gzipAsync(JSON.stringify(pages)), {
|
return await responseCompressed(req, JSON.stringify(pages));
|
||||||
headers: res.headers,
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
comp: async () => {
|
comp: async () => {
|
||||||
const comps = {} as Record<string, any>;
|
const comps = {} as Record<string, any>;
|
||||||
|
|
@ -102,9 +98,7 @@ export const _ = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Response(await gzipAsync(JSON.stringify(comps)), {
|
return await responseCompressed(req, JSON.stringify(comps));
|
||||||
headers: res.headers,
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
"load.json": async () => {
|
"load.json": async () => {
|
||||||
res.setHeader("content-type", "application/json");
|
res.setHeader("content-type", "application/json");
|
||||||
|
|
@ -244,3 +238,13 @@ const getPrisma = async (path: string) => {
|
||||||
|
|
||||||
return JSON.stringify({});
|
return JSON.stringify({});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const responseCompressed = async (req: Request, body: string) => {
|
||||||
|
if (req.headers.get("accept-encoding")?.includes("gz")) {
|
||||||
|
return new Response(await gzipAsync(body), {
|
||||||
|
headers: { "content-encoding": "gzip" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(body);
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue