diff --git a/pkgs/api/_prasi.ts b/pkgs/api/_prasi.ts index e9ba5a8..dd42556 100644 --- a/pkgs/api/_prasi.ts +++ b/pkgs/api/_prasi.ts @@ -4,6 +4,9 @@ import { gzipAsync } from "utils/gzip"; import { getContent } from "../server/prep-api-ts"; import mime from "mime"; +const cache = { + route: null as any, +}; export const _ = { url: "/_prasi/**", async api() { @@ -32,13 +35,15 @@ export const _ = { }, route: async () => { if (gz) { + if (cache.route) return cache.route; + let layout = null as null | SinglePage; for (const l of gz.layouts) { if (!layout) layout = l; if (l.is_default_layout) layout = l; } - return await responseCompressed( + cache.route = await responseCompressed( req, JSON.stringify({ site: { ...gz.site, api_url: (gz.site as any)?.config?.api_url }, @@ -51,6 +56,8 @@ export const _ = { }, }) ); + + return cache.route; } }, page: async () => {