summaryrefslogtreecommitdiff
path: root/packages/integrations/node
diff options
context:
space:
mode:
authorGravatar Elian ☕️ <hello@elian.codes> 2023-09-28 15:48:03 +0200
committerGravatar GitHub <noreply@github.com> 2023-09-28 15:48:03 +0200
commitec249f7a983926ba89248a3cc88cb1100a85168f (patch)
tree3232def95dc4cb3aa832f1ab4e44903b6986fc9e /packages/integrations/node
parent0ab19ba6152ea56c1fffaf9810465b4c29704398 (diff)
downloadastro-ec249f7a983926ba89248a3cc88cb1100a85168f.tar.gz
astro-ec249f7a983926ba89248a3cc88cb1100a85168f.tar.zst
astro-ec249f7a983926ba89248a3cc88cb1100a85168f.zip
update all the readme's for expressive code (#8691)
Co-authored-by: HiDeoo <HiDeoo@users.noreply.github.com> Co-authored-by: Genteure <Genteure@users.noreply.github.com> Co-authored-by: Bryce Russell <brycetrussell@gmail.com> Co-authored-by: Reuben Tier <TheOtterlord@users.noreply.github.com> Co-authored-by: Hippo <hippotastic@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> Co-authored-by: Kevin Zuniga Cuellar <kevinzunigacuellar@users.noreply.github.com>
Diffstat (limited to 'packages/integrations/node')
-rw-r--r--packages/integrations/node/README.md53
1 files changed, 28 insertions, 25 deletions
diff --git a/packages/integrations/node/README.md b/packages/integrations/node/README.md
index ecc4eb02f..26bac1f8c 100644
--- a/packages/integrations/node/README.md
+++ b/packages/integrations/node/README.md
@@ -43,17 +43,17 @@ If you prefer to install the adapter manually instead, complete the following tw
1. Add two new lines to your `astro.config.mjs` project configuration file.
- ```js ins={3, 6-9}
- // astro.config.mjs
- import { defineConfig } from 'astro/config';
- import node from '@astrojs/node';
-
- export default defineConfig({
- output: 'server',
- adapter: node({
- mode: 'standalone',
- }),
- });
+ ```diff lang="js"
+ // astro.config.mjs
+ import { defineConfig } from 'astro/config';
+ + import node from '@astrojs/node';
+
+ export default defineConfig({
+ + output: 'server',
+ + adapter: node({
+ + mode: 'standalone',
+ + }),
+ });
```
## Configuration
@@ -67,6 +67,7 @@ Controls whether the adapter builds to `middleware` or `standalone` mode.
- `middleware` mode allows the built output to be used as middleware for another Node.js server, like Express.js or Fastify.
```js
+ // astro.config.mjs
import { defineConfig } from 'astro/config';
import node from '@astrojs/node';
@@ -91,6 +92,7 @@ The server entrypoint is built to `./dist/server/entry.mjs` by default. This mod
For example, with Express:
```js
+// run-server.mjs
import express from 'express';
import { handler as ssrHandler } from './dist/server/entry.mjs';
@@ -107,6 +109,7 @@ app.listen(8080);
Or, with Fastify (>4):
```js
+// run-server.mjs
import Fastify from 'fastify';
import fastifyMiddie from '@fastify/middie';
import fastifyStatic from '@fastify/static';
@@ -128,6 +131,7 @@ app.listen({ port: 8080 });
Additionally, you can also pass in an object to be accessed with `Astro.locals` or in Astro middleware:
```js
+// run-server.mjs
import express from 'express';
import { handler as ssrHandler } from './dist/server/entry.mjs';
@@ -192,21 +196,20 @@ export $(cat .env.runtime) && astro build
You may see this when running the entry script if it was built with npm or Yarn. This is a known issue that may be fixed in a future release. As a workaround, add `"path-to-regexp"` to the `noExternal` array:
-```js ins={9-13}
-// astro.config.mjs
-import { defineConfig } from 'astro/config';
-
-import node from '@astrojs/node';
+```diff lang="js"
+ // astro.config.mjs
+ import { defineConfig } from 'astro/config';
+ import node from '@astrojs/node';
-export default defineConfig({
- output: 'server',
- adapter: node(),
- vite: {
- ssr: {
- noExternal: ['path-to-regexp'],
- },
- },
-});
+ export default defineConfig({
+ output: 'server',
+ adapter: node(),
++ vite: {
++ ssr: {
++ noExternal: ['path-to-regexp'],
++ },
++ },
+ });
```
For more help, check out the `#support` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help!