summaryrefslogtreecommitdiff
path: root/packages/integrations/node
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations/node')
-rw-r--r--packages/integrations/node/README.md109
-rw-r--r--packages/integrations/node/readme.md54
2 files changed, 109 insertions, 54 deletions
diff --git a/packages/integrations/node/README.md b/packages/integrations/node/README.md
new file mode 100644
index 000000000..ad8629e1a
--- /dev/null
+++ b/packages/integrations/node/README.md
@@ -0,0 +1,109 @@
+# @astrojs/node 🔲
+
+This adapter allows Astro to deploy your SSR site to Node targets.
+
+- <strong>[Why Astro Node](#why-astro-node)</strong>
+- <strong>[Installation](#installation)</strong>
+- <strong>[Usage](#usage)</strong>
+- <strong>[Configuration](#configuration)</strong>
+- <strong>[Examples](#examples)</strong>
+- <strong>[Troubleshooting](#troubleshooting)</strong>
+- <strong>[Contributing](#contributing)</strong>
+- <strong>[Changelog](#changelog)</strong>
+
+
+## Why Astro Node
+
+If you're using Astro as a static site builder—its behavior out of the box—you don't need an adapter.
+
+If you wish to [use server-side rendering (SSR)](https://docs.astro.build/en/guides/server-side-rendering/), Astro requires an adapter that matches your deployment runtime.
+
+[Node](https://nodejs.org/en/) is a JavaScript runtime for server-side code. Frameworks like [Express](https://expressjs.com/) are built on top of it and make it easier to write server applications in Node. This adapter provides access to Node's API and creates a script to run your Astro project that can be utilized in Node applications.
+
+## Installation
+
+First, install the `@astrojs/node` package using your package manager. If you're using npm or aren't sure, run this in the terminal:
+```sh
+npm install @astrojs/node
+```
+
+Then, install this adapter in your `astro.config.*` file using the `adapter` property:
+
+__astro.config.mjs__
+
+```js
+import { defineConfig } from 'astro/config';
+import deno from '@astrojs/node';
+
+export default defineConfig({
+ // ...
+ adapter: node()
+})
+```
+
+## Usage
+
+After [performing a build](https://docs.astro.build/en/guides/deploy/#building-the-app) there will be a `dist/server/entry.mjs` module that exposes a `handler` function. This works like a [middleware](https://expressjs.com/en/guide/using-middleware.html) function: it can handle incoming requests and respond accordingly.
+
+
+### Using a middleware framework
+You can use this `handler` with any framework that supports the Node `request` and `response` objects.
+
+For example, with Express:
+
+```js
+import express from 'express';
+import { handler as ssrHandler } from './dist/server/entry.mjs';
+
+const app = express();
+app.use(ssrHandler);
+
+app.listen(8080);
+```
+
+
+### Using `http`
+
+This output script does not require you use Express and can work with even the built-in `http` and `https` node modules. The handler does follow the convention calling an error function when either
+
+- A route is not found for the request.
+- There was an error rendering.
+
+You can use these to implement your own 404 behavior like so:
+
+```js
+import http from 'http';
+import { handler as ssrHandler } from './dist/server/entry.mjs';
+
+http.createServer(function(req, res) {
+ ssrHandler(req, res, err => {
+ if(err) {
+ res.writeHead(500);
+ res.end(err.toString());
+ } else {
+ // Serve your static assets here maybe?
+ // 404?
+ res.writeHead(404);
+ res.end();
+ }
+ });
+}).listen(8080);
+```
+
+
+
+## Configuration
+
+This adapter does not expose any configuration options.
+
+## Examples
+
+## Troubleshooting
+
+## Contributing
+
+This package is maintained by Astro's Core team. You're welcome to submit an issue or PR!
+
+## Changelog
+
+[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/
diff --git a/packages/integrations/node/readme.md b/packages/integrations/node/readme.md
deleted file mode 100644
index ffd4b6ffa..000000000
--- a/packages/integrations/node/readme.md
+++ /dev/null
@@ -1,54 +0,0 @@
-# @astrojs/node
-
-An experimental server-side rendering adapter for use with Node.js servers.
-
-In your astro.config.mjs use:
-
-```js
-import { defineConfig } from 'astro/config';
-import nodejs from '@astrojs/node';
-
-export default defineConfig({
- adapter: nodejs()
-})
-```
-
-After performing a build there will be a `dist/server/entry.mjs` module that works like a middleware function. You can use with any framework that supports the Node `request` and `response` objects. For example, with Express you can do:
-
-```js
-import express from 'express';
-import { handler as ssrHandler } from './dist/server/entry.mjs';
-
-const app = express();
-app.use(ssrHandler);
-
-app.listen(8080);
-```
-
-# Using `http`
-
-This adapter does not require you use Express and can work with even the `http` and `https` modules. The adapter does following the Expression convention of calling a function when either
-
-- A route is not found for the request.
-- There was an error rendering.
-
-You can use these to implement your own 404 behavior like so:
-
-```js
-import http from 'http';
-import { handler as ssrHandler } from './dist/server/entry.mjs';
-
-http.createServer(function(req, res) {
- ssrHandler(req, res, err => {
- if(err) {
- res.writeHead(500);
- res.end(err.toString());
- } else {
- // Serve your static assets here maybe?
- // 404?
- res.writeHead(404);
- res.end();
- }
- });
-}).listen(8080);
-```