Skip to content

Commit

Permalink
cleanup events
Browse files Browse the repository at this point in the history
  • Loading branch information
nksaraf committed Sep 25, 2023
1 parent 416239a commit 6589a69
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions test/templates/react-ssr-fs/app/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,45 @@ export default eventHandler(async (event) => {
});

const assets = await clientManifest.inputs[clientManifest.handler].assets();
const events = {};

const base =
import.meta.env.BASE_URL === "/" ? undefined : import.meta.env.BASE_URL;

const stream = renderToPipeableStream(
<App assets={<Suspense>{assets.map((m) => renderAsset(m))}</Suspense>}>
<Router
ssrPath={
event.path
// event.path
}
base={base}
>
<Suspense>
{routes.map((route) => (
<Route
path={route.path}
key={route.path}
component={route.component}
/>
))}
</Suspense>
</Router>
</App>,
{
bootstrapModules: [
clientManifest.inputs[clientManifest.handler].output.path,
],
bootstrapScriptContent: `window.manifest = ${JSON.stringify(
await clientManifest.json(),
)}; window.base = ${JSON.stringify(base)};`,
},
);
const json = JSON.stringify(await clientManifest.json());
const stream = await new Promise((resolve) => {
const stream = renderToPipeableStream(
<App assets={<Suspense>{assets.map((m) => renderAsset(m))}</Suspense>}>
<Router
ssrPath={
event.path
// event.path
}
base={base}
>
<Suspense>
{routes.map((route) => (
<Route
path={route.path}
key={route.path}
component={route.component}
/>
))}
</Suspense>
</Router>
</App>,
{
onShellReady() {
resolve(stream);
},
bootstrapModules: [
clientManifest.inputs[clientManifest.handler].output.path,
],
bootstrapScriptContent: `window.manifest = ${json}; window.base = ${JSON.stringify(
base,
)};`,
},
);
});

setHeader(event, "Content-Type", "text/html");

Expand Down

0 comments on commit 6589a69

Please sign in to comment.