Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions goldens/public-api/angular/ssr/tokens/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import { InjectionToken } from '@angular/core';

// @public
export const REQUEST: InjectionToken<Request>;
export const REQUEST: InjectionToken<Request | null>;

// @public
export const REQUEST_CONTEXT: InjectionToken<unknown>;

// @public
export const RESPONSE_INIT: InjectionToken<ResponseInit>;
export const RESPONSE_INIT: InjectionToken<ResponseInit | null>;

// (No @packageDocumentation comment for this package)

Expand Down
53 changes: 48 additions & 5 deletions packages/angular/ssr/tokens/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>('REQUEST');
export const REQUEST = new InjectionToken<Request | null>('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<ResponseInit>('RESPONSE_INIT');
export const RESPONSE_INIT = new InjectionToken<ResponseInit | null>('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<unknown>('REQUEST_CONTEXT');
export const REQUEST_CONTEXT = new InjectionToken<unknown>('REQUEST_CONTEXT', {
providedIn: 'platform',
factory: () => null,
});