diff options
-rw-r--r-- | packages/astro/src/@types/astro.ts | 24 | ||||
-rw-r--r-- | packages/astro/src/core/README.md | 2 | ||||
-rw-r--r-- | packages/astro/src/core/constants.ts | 6 | ||||
-rw-r--r-- | packages/astro/src/core/request.ts | 4 |
4 files changed, 19 insertions, 17 deletions
diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 01925212f..010815695 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -2353,7 +2353,7 @@ interface AstroSharedContext< > { /** * The address (usually IP address) of the user. - * + * * Throws an error if used within a static site, or within a prerendered page. */ clientAddress: string; @@ -2407,7 +2407,7 @@ interface AstroSharedContext< /** * The `APIContext` is the object made available to endpoints and middleware. * It is a subset of the `Astro` global object available in pages. - * + * * [Reference](https://docs.astro.build/en/reference/api-reference/#endpoint-context) */ export interface APIContext< @@ -2426,7 +2426,7 @@ export interface APIContext< generator: string; /** * The url of the current request, parsed as an instance of `URL`. - * + * * Equivalent to: * ```ts * new URL(context.request.url) @@ -2441,7 +2441,7 @@ export interface APIContext< * Example usage: * ```ts * import type { APIContext } from "astro" - * + * * export function getStaticPaths() { * return [ * { params: { id: '0' }, props: { name: 'Sarah' } }, @@ -2463,8 +2463,8 @@ export interface APIContext< * * Example usage: * ```ts - * import type { APIContext } from "astro" - * + * import type { APIContext } from "astro" + * * export function getStaticPaths() { * return [ * { params: { id: '0' }, props: { name: 'Sarah' } }, @@ -2477,13 +2477,13 @@ export interface APIContext< * return new Response(`Hello ${props.name}!`); * } * ``` - * + * * [Reference](https://docs.astro.build/en/guides/api-reference/#contextprops) */ props: AstroSharedContext<Props, APIParams>['props']; /** * Create a response that redirects to another page. - * + * * Example usage: * ```ts * // src/pages/secret.ts @@ -2498,11 +2498,11 @@ export interface APIContext< /** * An object that middlewares can use to store extra information related to the request. - * + * * It will be made available to pages as `Astro.locals`, and to endpoints as `context.locals`. - * + * * Example usage: - * + * * ```ts * // src/middleware.ts * import { defineMiddleware } from "astro:middleware"; @@ -2520,7 +2520,7 @@ export interface APIContext< * --- * <h1>{greeting}</h1> * ``` - * + * * [Reference](https://docs.astro.build/en/reference/api-reference/#contextlocals) */ locals: App.Locals; diff --git a/packages/astro/src/core/README.md b/packages/astro/src/core/README.md index 94eff9e05..bc04c3501 100644 --- a/packages/astro/src/core/README.md +++ b/packages/astro/src/core/README.md @@ -3,6 +3,7 @@ Code that executes directly on Node (not processed by vite). Contains the main Astro logic for the `build`, `dev`, `preview`, and `sync` commands, and also manages the lifecycle of the Vite server. The `core/index.ts` module exports the CLI commands as functions and is the main entrypoint of the `astro` package. + ```ts import { dev, build, preview, sync } from 'astro'; ``` @@ -40,6 +41,7 @@ vite-plugin-astro-server --------- DevPipeline ------ Pipeline ------------- Ren The pipeline is an interface representing data that stays unchanged throughout the duration of the server or build. For example: the user configuration, the list of pages and endpoints in the project, and environment-specific way of gathering scripts and styles. There are 3 implementations of the pipeline: + - `DevPipeline`: in-use during the `astro dev` CLI command. Created and used by `vite-plugin-astro-server`, and then forwarded to other internals. - `BuildPipeline`: in-use during the `astro build` command in `"static"` mode, and for prerendering in `"server"` and `"hybrid"` output modes. See `core/build/`. - `AppPipeline`: in-use during production server(less) deployments. Created and used by `App` (see `core/app/`), and then forwarded to other internals. diff --git a/packages/astro/src/core/constants.ts b/packages/astro/src/core/constants.ts index c7431aa96..f1b10a525 100644 --- a/packages/astro/src/core/constants.ts +++ b/packages/astro/src/core/constants.ts @@ -4,7 +4,7 @@ export const ASTRO_VERSION = process.env.PACKAGE_VERSION ?? 'development'; /** * The name for the header used to help rerouting behavior. * When set to "no", astro will NOT try to reroute an error response to the corresponding error page, which is the default behavior that can sometimes lead to loops. - * + * * ```ts * const response = new Response("keep this content as-is", { * status: 404, @@ -52,9 +52,9 @@ export const clientLocalsSymbol = Symbol.for('astro.locals'); /** * The symbol used as a field on the response object to keep track of streaming. - * + * * It is set when the `<head>` element has been completely generated, rendered, and the response object has been passed onto the adapter. - * + * * Used to provide helpful errors and warnings when headers or cookies are added during streaming, after the response has already been sent. */ export const responseSentSymbol = Symbol.for('astro.responseSent'); diff --git a/packages/astro/src/core/request.ts b/packages/astro/src/core/request.ts index 8445792af..423f8a965 100644 --- a/packages/astro/src/core/request.ts +++ b/packages/astro/src/core/request.ts @@ -29,9 +29,9 @@ const clientLocalsSymbol = Symbol.for('astro.locals'); /** * Used by astro internals to create a web standard request object. - * + * * The user of this function may provide the data in a runtime-agnostic way. - * + * * This is used by the static build to create fake requests for prerendering, and by the dev server to convert node requests into the standard request object. */ export function createRequest({ |