You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/en/reference/adapter-reference.mdx
+45-44Lines changed: 45 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -166,7 +166,7 @@ export default function createIntegration() {
166
166
**Type:**`URLSearchParams`
167
167
</p>
168
168
169
-
Define the query parameters to append to all asset URLs (e.g. images, stylesheets, scripts, etc.). This is useful for adapters that need to track deployment versions or other metadata.
169
+
Defines the query parameters to append to all asset URLs (e.g. images, stylesheets, scripts). This is useful for adapters that need to track deployment versions or other metadata.
170
170
171
171
The following example retrieves a `DEPLOY_ID` from the environment variables and, if provided, returns an object with a custom search parameter name as key and the deploy id as value:
172
172
@@ -257,7 +257,7 @@ You will need to create a file that executes during server-side requests to enab
An exported function that takes an SSR manifest as its first argument and an object containing your adapter [args](#args) as its second argument. This should provide the exports required by your host.
260
+
An exported function that takes an SSR manifest as its first argument and an object containing your adapter [`args`](#args) as its second argument. This should provide the exports required by your host.
261
261
262
262
For example, some serverless hosts expect you to export an `handler()` function. With the adapter API, you achieve this by implementing `createExports()` in your server entrypoint:
263
263
@@ -317,9 +317,9 @@ export function createExports(manifest, args) {
An exported function that takes an SSR manifest as its first argument and an object containing your adapter [args](#args) as its second argument.
320
+
An exported function that takes an SSR manifest as its first argument and an object containing your adapter [`args`](#args) as its second argument.
321
321
322
-
Some hosts expect you to *start* the server yourselves, for example, by listening to a port. For these types of hosts, the adapter API allows you to export a `start` function, which will be called when the bundle script is run.
322
+
Some hosts expect you to *start* the server yourselves, for example, by listening to a port. For these types of hosts, the adapter API allows you to export a `start()` function, which will be called when the bundle script is run.
323
323
324
324
```js title="my-adapter/server.js"
325
325
import { App } from'astro/app';
@@ -335,7 +335,7 @@ export function start(manifest) {
335
335
336
336
### `astro/app`
337
337
338
-
This module is used for rendering pages that have been prebuilt through `astro build`. Astro uses the standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) objects. Hosts that have a different API for request/response should convert to these types in their adapter.
338
+
This module is used for rendering pages that have been prebuilt through `astro build`. Astro uses the standard [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) and [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) objects. Hosts that have a different API for request/response should convert to these types in their adapter.
339
339
340
340
The `App` constructor accepts a required SSR manifest argument, and optionally an argument to enable or disable streaming, defaulting to `true`.
341
341
@@ -427,11 +427,11 @@ The example below reads a header named `x-private-header`, attempts to parse it
@@ -479,15 +480,15 @@ If not provided, Astro will fallback to its default behavior for fetching error
479
480
**Default:**`app.match(request)`
480
481
</p>
481
482
482
-
Provide a value for [`integrationRouteData`](/en/reference/integrations-reference/#integrationroutedata-type-reference) if you already know the route to render. Doing so will bypass the internal call to [`app.match`](#appmatch) to determine the route to render.
483
+
Provides a value for [`integrationRouteData`](/en/reference/integrations-reference/#integrationroutedata-type-reference) if you already know the route to render. Doing so will bypass the internal call to [`app.match()`](#appmatch) to determine the route to render.
483
484
484
485
```js "routeData"
485
486
constrouteData=app.match(request);
486
487
if (routeData) {
487
-
returnapp.render(request, { routeData });
488
+
returnapp.render(request, { routeData });
488
489
} else {
489
-
/* adapter-specific 404 response */
490
-
returnnewResponse(..., { status:404 });
490
+
/* adapter-specific 404 response */
491
+
returnnewResponse(..., { status:404 });
491
492
}
492
493
```
493
494
@@ -748,7 +749,7 @@ nodeApp.setHeadersMap([
748
749
749
750
Converts a NodeJS `IncomingMessage` into a standard `Request` object. This static method accepts an optional object as the second argument, allowing you to define if the body should be ignored, defaulting to `false`, and the [`allowedDomains`](/en/reference/configuration-reference/#securityalloweddomains).
750
751
751
-
The following example creates a `Request` and passes it to `app.render`:
752
+
The following example creates a `Request` and passes it to `app.render()`:
Streams a web-standard `Response` into a NodeJS server response. This static method takes a `Response` object and the initial `ServerResponse` before returning a promise of a `ServerResponse` object.
772
773
773
-
The following example creates a `Request`, passes it to `app.render`, and writes the response:
774
+
The following example creates a `Request`, passes it to `app.render()`, and writes the response:
774
775
775
776
```js {7}
776
777
import { NodeApp } from'astro/app/node';
777
778
import { createServer } from'node:http';
778
779
779
780
constserver=createServer(async (req, res) => {
780
-
constrequest=NodeApp.createRequest(req);
781
-
constresponse=awaitapp.render(request);
782
-
awaitNodeApp.writeResponse(response, res);
781
+
constrequest=NodeApp.createRequest(req);
782
+
constresponse=awaitapp.render(request);
783
+
awaitNodeApp.writeResponse(response, res);
783
784
})
784
785
```
785
786
@@ -907,7 +908,7 @@ export default function createIntegration() {
907
908
name:'@example/my-adapter',
908
909
serverEntrypoint:'@example/my-adapter/server.js',
909
910
supportedAstroFeatures: {
910
-
envGetSecret:'stable'
911
+
envGetSecret:'stable'
911
912
}
912
913
});
913
914
},
@@ -944,21 +945,21 @@ import { setGetEnv } from 'astro/env/setup';
0 commit comments