MCPcopy Create free account
hub / github.com/ethanniser/the-beth-stack / bethStack

Function bethStack

packages/beth-stack/src/elysia/index.ts:10–37  ·  view source on GitHub ↗
(options: Partial<BethPluginOptions> = {})

Source from the content-addressed store, hash-verified

8type BethPluginOptions = GlobalCacheConfig;
9
10export function bethStack(options: Partial<BethPluginOptions> = {}) {
11 // setGlobalPersistCacheConfig(options);
12
13 async function html<T extends () => JSX.Element>(
14 lazyHtml: T,
15 ): Promise<Response> {
16 return renderToStringResponse(lazyHtml);
17 }
18
19 function htmlStream<T extends () => JSX.Element>(lazyHtml: T): Response {
20 return renderToStreamResponse(lazyHtml);
21 }
22
23 return function bethPlugin(app: Elysia) {
24 return app.decorate("html", html).decorate("htmlStream", htmlStream);
25 // ! FIX WHEN ELYSIA IS FIXED
26 // .onRequest(() => {
27 // BETH_GLOBAL_RENDER_CACHE.reset();
28 // // elysia is weird idk
29 // return void 0;
30 // })
31 // .onResponse(() => {
32 // BETH_GLOBAL_RENDER_CACHE.reset();
33 // // elysia is weird idk
34 // return void 0;
35 // });
36 };
37}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected