summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Edvinas Jurele <73230019+edv-ns@users.noreply.github.com> 2023-02-07 20:58:37 +0200
committerGravatar GitHub <noreply@github.com> 2023-02-07 13:58:37 -0500
commit92dcf81c17d7145bbd5f6e1d731bb9cb84a146d7 (patch)
tree6b89914ccd65f1e692c978b402929f726d83e00e
parent27eecd399822c45a4e6a373401b2464e646206bd (diff)
downloadastro-92dcf81c17d7145bbd5f6e1d731bb9cb84a146d7.tar.gz
astro-92dcf81c17d7145bbd5f6e1d731bb9cb84a146d7.tar.zst
astro-92dcf81c17d7145bbd5f6e1d731bb9cb84a146d7.zip
update node integration README with Fastify code example (#6120)
-rw-r--r--packages/integrations/node/README.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/integrations/node/README.md b/packages/integrations/node/README.md
index 11a9d97f1..3eb8d1caf 100644
--- a/packages/integrations/node/README.md
+++ b/packages/integrations/node/README.md
@@ -98,6 +98,27 @@ app.use(ssrHandler);
app.listen(8080);
```
+Or, with Fastify (>4):
+
+```js
+import Fastify from 'fastify';
+import fastifyMiddie from '@fastify/middie';
+import fastifyStatic from '@fastify/static';
+import { fileURLToPath } from 'url';
+import { handler as ssrHandler } from './dist/server/entry.mjs';
+
+const app = Fastify({ logger: true });
+
+await app
+ .register(fastifyStatic, {
+ root: fileURLToPath(new URL('./dist/client', import.meta.url)),
+ })
+ .register(fastifyMiddie);
+app.use(ssrHandler);
+
+app.listen({ port: 8080 });
+```
+
Note that middleware mode does not do file serving. You'll need to configure your HTTP framework to do that for you. By default the client assets are written to `./dist/client/`.
### Standalone