Skip to content

Commit 6515aab

Browse files
fix(adapter-reference): small nitpicks (verb tense, indentation...) (#12706)
Co-authored-by: Sarah Rainsberger <[email protected]>
1 parent 856e076 commit 6515aab

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

src/content/docs/en/reference/adapter-reference.mdx

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export default function createIntegration() {
166166
**Type:** `URLSearchParams`
167167
</p>
168168

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.
170170

171171
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:
172172

@@ -257,7 +257,7 @@ You will need to create a file that executes during server-side requests to enab
257257
Type: `(manifest: SSRManifest, options: any) => Record<string, any>`
258258
</p>
259259

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.
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.
261261

262262
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:
263263

@@ -317,9 +317,9 @@ export function createExports(manifest, args) {
317317
Type: `(manifest: SSRManifest, options: any) => Record<string, any>`
318318
</p>
319319

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.
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.
321321

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.
323323

324324
```js title="my-adapter/server.js"
325325
import { App } from 'astro/app';
@@ -335,7 +335,7 @@ export function start(manifest) {
335335

336336
### `astro/app`
337337

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.
339339

340340
The `App` constructor accepts a required SSR manifest argument, and optionally an argument to enable or disable streaming, defaulting to `true`.
341341

@@ -427,11 +427,11 @@ The example below reads a header named `x-private-header`, attempts to parse it
427427
const privateHeader = request.headers.get("x-private-header");
428428
let locals = {};
429429
try {
430-
if (privateHeader) {
431-
locals = JSON.parse(privateHeader);
432-
}
430+
if (privateHeader) {
431+
locals = JSON.parse(privateHeader);
432+
}
433433
} finally {
434-
const response = await app.render(request, { locals });
434+
const response = await app.render(request, { locals });
435435
}
436436
```
437437

@@ -450,22 +450,23 @@ This is used to override the default `fetch()` behavior, for example, when `fetc
450450

451451
The following example reads `500.html` and `404.html` from disk instead of performing an HTTP call:
452452

453-
```js "prerenderedErrorPageFetch"
453+
```ts "prerenderedErrorPageFetch"
454454
return app.render(request, {
455455
prerenderedErrorPageFetch: async (url: string): Promise<Response> => {
456456
if (url.includes("/500")) {
457-
const content = await fs.promises.readFile("500.html", "utf-8");
458-
return new Response(content, {
459-
status: 500,
460-
headers: { "Content-Type": "text/html" },
461-
});
462-
}
463-
464-
const content = await fs.promises.readFile("404.html", "utf-8");
457+
const content = await fs.promises.readFile("500.html", "utf-8");
465458
return new Response(content, {
466-
status: 404,
459+
status: 500,
467460
headers: { "Content-Type": "text/html" },
468461
});
462+
}
463+
464+
const content = await fs.promises.readFile("404.html", "utf-8");
465+
return new Response(content, {
466+
status: 404,
467+
headers: { "Content-Type": "text/html" },
468+
});
469+
}
469470
});
470471
```
471472

@@ -479,15 +480,15 @@ If not provided, Astro will fallback to its default behavior for fetching error
479480
**Default:** `app.match(request)`
480481
</p>
481482

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.
483484

484485
```js "routeData"
485486
const routeData = app.match(request);
486487
if (routeData) {
487-
return app.render(request, { routeData });
488+
return app.render(request, { routeData });
488489
} else {
489-
/* adapter-specific 404 response */
490-
return new Response(..., { status: 404 });
490+
/* adapter-specific 404 response */
491+
return new Response(..., { status: 404 });
491492
}
492493
```
493494

@@ -748,7 +749,7 @@ nodeApp.setHeadersMap([
748749
749750
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).
750751
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()`:
752753
753754
```js {5}
754755
import { NodeApp } from 'astro/app/node';
@@ -770,16 +771,16 @@ const server = createServer(async (req, res) => {
770771
771772
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.
772773
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:
774775
775776
```js {7}
776777
import { NodeApp } from 'astro/app/node';
777778
import { createServer } from 'node:http';
778779

779780
const server = createServer(async (req, res) => {
780-
const request = NodeApp.createRequest(req);
781-
const response = await app.render(request);
782-
await NodeApp.writeResponse(response, res);
781+
const request = NodeApp.createRequest(req);
782+
const response = await app.render(request);
783+
await NodeApp.writeResponse(response, res);
783784
})
784785
```
785786
@@ -907,7 +908,7 @@ export default function createIntegration() {
907908
name: '@example/my-adapter',
908909
serverEntrypoint: '@example/my-adapter/server.js',
909910
supportedAstroFeatures: {
910-
envGetSecret: 'stable'
911+
envGetSecret: 'stable'
911912
}
912913
});
913914
},
@@ -944,21 +945,21 @@ import { setGetEnv } from 'astro/env/setup';
944945
import { createGetEnv } from '../utils/env.js';
945946

946947
type Env = {
947-
[key: string]: unknown;
948+
[key: string]: unknown;
948949
};
949950

950951
export function createExports(manifest: SSRManifest) {
951-
const app = new App(manifest);
952+
const app = new App(manifest);
952953

953-
const fetch = async (request: Request, env: Env) => {
954-
setGetEnv(createGetEnv(env));
954+
const fetch = async (request: Request, env: Env) => {
955+
setGetEnv(createGetEnv(env));
955956

956-
const response = await app.render(request);
957+
const response = await app.render(request);
957958

958-
return response;
959-
};
959+
return response;
960+
};
960961

961-
return { default: { fetch } };
962+
return { default: { fetch } };
962963
}
963964
```
964965
@@ -997,7 +998,7 @@ export default function createIntegration() {
997998
name: '@example/my-adapter',
998999
serverEntrypoint: '@example/my-adapter/server.js',
9991000
adapterFeatures: {
1000-
edgeMiddleware: true
1001+
edgeMiddleware: true
10011002
}
10021003
});
10031004
},
@@ -1018,23 +1019,23 @@ export default function createIntegration() {
10181019
name: '@example/my-adapter',
10191020
serverEntrypoint: '@example/my-adapter/server.js',
10201021
adapterFeatures: {
1021-
edgeMiddleware: true
1022+
edgeMiddleware: true
10221023
}
10231024
});
10241025
},
10251026

10261027
'astro:build:ssr': ({ middlewareEntryPoint }) => {
1027-
// remember to check if this property exits, it will be `undefined` if the adapter doesn't opt in to the feature
1028-
if (middlewareEntryPoint) {
1029-
createEdgeMiddleware(middlewareEntryPoint)
1030-
}
1028+
// remember to check if this property exits, it will be `undefined` if the adapter doesn't opt in to the feature
1029+
if (middlewareEntryPoint) {
1030+
createEdgeMiddleware(middlewareEntryPoint)
1031+
}
10311032
}
10321033
},
10331034
};
10341035
}
10351036

10361037
function createEdgeMiddleware(middlewareEntryPoint) {
1037-
// emit a new physical file using your bundler
1038+
// emit a new physical file using your bundler
10381039
}
10391040
```
10401041

0 commit comments

Comments
 (0)