diff --git a/goldens/public-api/angular/ssr/tokens/index.api.md b/goldens/public-api/angular/ssr/tokens/index.api.md index 6ac87558b1ad..ca962ea0c990 100644 --- a/goldens/public-api/angular/ssr/tokens/index.api.md +++ b/goldens/public-api/angular/ssr/tokens/index.api.md @@ -7,13 +7,13 @@ import { InjectionToken } from '@angular/core'; // @public -export const REQUEST: InjectionToken; +export const REQUEST: InjectionToken; // @public export const REQUEST_CONTEXT: InjectionToken; // @public -export const RESPONSE_INIT: InjectionToken; +export const RESPONSE_INIT: InjectionToken; // (No @packageDocumentation comment for this package) diff --git a/packages/angular/ssr/tokens/src/tokens.ts b/packages/angular/ssr/tokens/src/tokens.ts index a04f19958edb..90b664bef6d4 100644 --- a/packages/angular/ssr/tokens/src/tokens.ts +++ b/packages/angular/ssr/tokens/src/tokens.ts @@ -9,19 +9,62 @@ import { InjectionToken } from '@angular/core'; /** - * Injection token for the current request. + * Injection token representing the current HTTP request object. + * + * Use this token to access the current request when handling server-side + * rendering (SSR). + * + * @remarks + * This token may be `null` in the following scenarios: + * + * * During the build processes. + * * When the application is rendered in the browser (client-side rendering). + * * When performing static site generation (SSG). + * * During route extraction in development (at the time of the request). + * + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request | `Request` on MDN} + * * @developerPreview */ -export const REQUEST = new InjectionToken('REQUEST'); +export const REQUEST = new InjectionToken('REQUEST', { + providedIn: 'platform', + factory: () => null, +}); /** - * Injection token for the response initialization options. + * Injection token for response initialization options. + * + * Use this token to provide response options for configuring or initializing + * HTTP responses in server-side rendering or API endpoints. + * + * @remarks + * This token may be `null` in the following scenarios: + * + * * During the build processes. + * * When the application is rendered in the browser (client-side rendering). + * * When performing static site generation (SSG). + * * During route extraction in development (at the time of the request). + * + * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/Response | `ResponseInit` on MDN} + * * @developerPreview */ -export const RESPONSE_INIT = new InjectionToken('RESPONSE_INIT'); +export const RESPONSE_INIT = new InjectionToken('RESPONSE_INIT', { + providedIn: 'platform', + factory: () => null, +}); /** * Injection token for additional request context. + * + * Use this token to pass custom metadata or context related to the current request in server-side rendering. + * + * @remarks + * This token is only available during server-side rendering and will be `null` in other contexts. + * * @developerPreview */ -export const REQUEST_CONTEXT = new InjectionToken('REQUEST_CONTEXT'); +export const REQUEST_CONTEXT = new InjectionToken('REQUEST_CONTEXT', { + providedIn: 'platform', + factory: () => null, +});