diff --git a/apps/docs/src/server/content/_preview.md b/apps/docs/src/server/content/_preview.md index 59dacdf..84e6828 100644 --- a/apps/docs/src/server/content/_preview.md +++ b/apps/docs/src/server/content/_preview.md @@ -3,7 +3,7 @@ import { html } from "client:page"; export const handler = async (req: Request) => { return new Response( - html, // Bundled client application. + html, // bundled client application { headers: { "Content-Type": "text/html" }, }, diff --git a/apps/docs/src/server/content/deploy.md b/apps/docs/src/server/content/deploy.md index d2d2453..f26895f 100644 --- a/apps/docs/src/server/content/deploy.md +++ b/apps/docs/src/server/content/deploy.md @@ -27,18 +27,18 @@ Here's an example of how to serve your app using the result of your build using ```ts // server.js -// Import the `handler` from the build output. +// import the `handler` from the build output import { handler } from "./dist/server/app.js"; -// Converts web handler to a Node compatible request listener. +// converts web handler to a Node compatible request listener import { nodeListener } from "domco/listener"; import { createServer } from "node:http"; -// `sirv` serves static assets. +// `sirv` serves static assets import sirv from "sirv"; const assets = sirv("dist/client", { etag: true, setHeaders: (res, pathname) => { - // Serve `dist/client/_immutable/*` with immutable headers. + // serve `dist/client/_immutable/*` with immutable headers if (pathname.startsWith("/_immutable/")) { res.setHeader("Cache-Control", "public, max-age=31536000, immutable"); } @@ -46,9 +46,9 @@ const assets = sirv("dist/client", { }); const server = createServer((req, res) => - // First, look for a static asset. + // first, look for a static asset assets(req, res, () => - // Fallthrough to the handler if static asset is not found. + // fallthrough to the handler if static asset is not found nodeListener(handler)(req, res), ), ); diff --git a/apps/docs/src/server/content/examples.md b/apps/docs/src/server/content/examples.md index e8f1d74..073f6a4 100644 --- a/apps/docs/src/server/content/examples.md +++ b/apps/docs/src/server/content/examples.md @@ -49,13 +49,13 @@ import { html } from "client:page"; import type { Handler } from "domco"; import { Trouter, type Methods } from "trouter"; -// Custom context variable. +// custom context variable type Context = { req: Request; params: Record; }; -// Custom handler/middleware. +// custom handler/middleware type RouteHandler = (context: Context) => Promise; const router = new Trouter(); @@ -82,10 +82,10 @@ export const handler: Handler = async (req) => { const { handlers, params } = router.find(req.method as Methods, pathname); for (const h of handlers) { - // Create context. + // create context const context: Context = { req, params }; - // Pass into handler. + // pass into handler const res = await h(context); if (res instanceof Response) { diff --git a/apps/docs/src/server/content/migrate.md b/apps/docs/src/server/content/migrate.md index 70411d4..8e0ddb0 100644 --- a/apps/docs/src/server/content/migrate.md +++ b/apps/docs/src/server/content/migrate.md @@ -98,9 +98,9 @@ Create a server entry `src/server/+app.tsx` file. ```tsx // /src/server/+app.tsx -// Import your App. +// import your App import App from "../app/App"; -// Import the HTML page. +// import the HTML page import { html } from "client:page"; import { StrictMode } from "react"; import { renderToString } from "react-dom/server"; @@ -108,7 +108,7 @@ import { renderToString } from "react-dom/server"; export const handler = async (_req: Request) => { return new Response( html.replace( - "%root%", // replace the text "%root%" with the React App. + "%root%", // replace the text "%root%" with the React App renderToString( diff --git a/apps/docs/src/server/content/tutorial.md b/apps/docs/src/server/content/tutorial.md index 942326e..d9a9a08 100644 --- a/apps/docs/src/server/content/tutorial.md +++ b/apps/docs/src/server/content/tutorial.md @@ -111,7 +111,7 @@ import { html as otherHtml } from "client:page/other"; export const handler = async (req: Request) => { return new Response( - html, // Your Vite app. + html, // bundled client application { headers: { "Content-Type": "text/html" }, },