mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-15 01:54:04 +08:00
feat(@angular/ssr): stabilize AngularNodeAppEngine
, AngularAppEngine
, and provideServerRouting
APIs
This commit promotes the `AngularNodeAppEngine`, `AngularAppEngine`, and `provideServerRouting` APIs from dev preview to stable. These APIs enhance server-side rendering (SSR) capabilities in Angular applications, improving routing and server integration for better performance and reliability.
This commit is contained in:
parent
b9591eb4b6
commit
cdfc50c29a
@ -18,8 +18,6 @@ import { createWebRequestFromNodeRequest } from './request';
|
||||
*
|
||||
* @remarks This class should be instantiated once and used as a singleton across the server-side
|
||||
* application to ensure consistent handling of rendering requests and resource management.
|
||||
*
|
||||
* @developerPreview
|
||||
*/
|
||||
export class AngularNodeAppEngine {
|
||||
private readonly angularAppEngine = new AngularAppEngine();
|
||||
|
@ -16,7 +16,6 @@ import type { IncomingMessage, ServerResponse } from 'node:http';
|
||||
* @param next - A callback function that signals the completion of the middleware or forwards the error if provided.
|
||||
*
|
||||
* @returns A Promise that resolves to void or simply void. The handler can be asynchronous.
|
||||
* @developerPreview
|
||||
*/
|
||||
export type NodeRequestHandlerFunction = (
|
||||
req: IncomingMessage,
|
||||
@ -66,7 +65,6 @@ export type NodeRequestHandlerFunction = (
|
||||
* res.send('Hello from Fastify with Node Next Handler!');
|
||||
* }));
|
||||
* ```
|
||||
* @developerPreview
|
||||
*/
|
||||
export function createNodeRequestHandler<T extends NodeRequestHandlerFunction>(handler: T): T {
|
||||
(handler as T & { __ng_node_request_handler__?: boolean })['__ng_node_request_handler__'] = true;
|
||||
|
@ -23,7 +23,6 @@ import { fileURLToPath } from 'node:url';
|
||||
*
|
||||
* @param url The URL of the module to check. This should typically be `import.meta.url`.
|
||||
* @returns `true` if the provided URL represents the main entry point, otherwise `false`.
|
||||
* @developerPreview
|
||||
*/
|
||||
export function isMainModule(url: string): boolean {
|
||||
return url.startsWith('file:') && argv[1] === fileURLToPath(url);
|
||||
|
@ -27,7 +27,6 @@ const HTTP2_PSEUDO_HEADERS = new Set([':method', ':scheme', ':authority', ':path
|
||||
*
|
||||
* @param nodeRequest - The Node.js request object (`IncomingMessage` or `Http2ServerRequest`) to convert.
|
||||
* @returns A Web Standard `Request` object.
|
||||
* @developerPreview
|
||||
*/
|
||||
export function createWebRequestFromNodeRequest(
|
||||
nodeRequest: IncomingMessage | Http2ServerRequest,
|
||||
|
@ -19,7 +19,6 @@ import type { Http2ServerResponse } from 'node:http2';
|
||||
* @param source - The web-standard `Response` object to stream from.
|
||||
* @param destination - The Node.js response object (`ServerResponse` or `Http2ServerResponse`) to stream into.
|
||||
* @returns A promise that resolves once the streaming operation is complete.
|
||||
* @developerPreview
|
||||
*/
|
||||
export async function writeResponseToNodeResponse(
|
||||
source: Response,
|
||||
|
@ -19,8 +19,6 @@ import { joinUrlParts } from './utils/url';
|
||||
*
|
||||
* @remarks This class should be instantiated once and used as a singleton across the server-side
|
||||
* application to ensure consistent handling of rendering requests and resource management.
|
||||
*
|
||||
* @developerPreview
|
||||
*/
|
||||
export class AngularAppEngine {
|
||||
/**
|
||||
|
@ -12,7 +12,6 @@
|
||||
* @param request - The incoming HTTP request object.
|
||||
* @returns A Promise resolving to a `Response` object, `null`, or directly a `Response`,
|
||||
* supporting both synchronous and asynchronous handling.
|
||||
* @developerPreview
|
||||
*/
|
||||
export type RequestHandlerFunction = (
|
||||
request: Request,
|
||||
@ -39,7 +38,6 @@ export type RequestHandlerFunction = (
|
||||
* const handler = toWebHandler(app);
|
||||
* export default createRequestHandler(handler);
|
||||
* ```
|
||||
* @developerPreview
|
||||
*/
|
||||
export function createRequestHandler(handler: RequestHandlerFunction): RequestHandlerFunction {
|
||||
(handler as RequestHandlerFunction & { __ng_request_handler__?: boolean })[
|
||||
|
@ -24,7 +24,6 @@ const APP_SHELL_ROUTE = 'ng-app-shell';
|
||||
/**
|
||||
* Identifies a particular kind of `ServerRoutesFeatureKind`.
|
||||
* @see {@link ServerRoutesFeature}
|
||||
* @developerPreview
|
||||
*/
|
||||
enum ServerRoutesFeatureKind {
|
||||
AppShell,
|
||||
@ -33,7 +32,6 @@ enum ServerRoutesFeatureKind {
|
||||
/**
|
||||
* Helper type to represent a server routes feature.
|
||||
* @see {@link ServerRoutesFeatureKind}
|
||||
* @developerPreview
|
||||
*/
|
||||
interface ServerRoutesFeature<FeatureKind extends ServerRoutesFeatureKind> {
|
||||
ɵkind: FeatureKind;
|
||||
@ -44,7 +42,6 @@ interface ServerRoutesFeature<FeatureKind extends ServerRoutesFeatureKind> {
|
||||
* Different rendering modes for server routes.
|
||||
* @see {@link provideServerRouting}
|
||||
* @see {@link ServerRoute}
|
||||
* @developerPreview
|
||||
*/
|
||||
export enum RenderMode {
|
||||
/** Server-Side Rendering (SSR) mode, where content is rendered on the server for each request. */
|
||||
@ -61,7 +58,6 @@ export enum RenderMode {
|
||||
* Defines the fallback strategies for Static Site Generation (SSG) routes when a pre-rendered path is not available.
|
||||
* This is particularly relevant for routes with parameterized URLs where some paths might not be pre-rendered at build time.
|
||||
* @see {@link ServerRoutePrerenderWithParams}
|
||||
* @developerPreview
|
||||
*/
|
||||
export enum PrerenderFallback {
|
||||
/**
|
||||
@ -85,7 +81,6 @@ export enum PrerenderFallback {
|
||||
|
||||
/**
|
||||
* Common interface for server routes, providing shared properties.
|
||||
* @developerPreview
|
||||
*/
|
||||
export interface ServerRouteCommon {
|
||||
/** The path associated with this route. */
|
||||
@ -101,7 +96,6 @@ export interface ServerRouteCommon {
|
||||
/**
|
||||
* A server route that uses Client-Side Rendering (CSR) mode.
|
||||
* @see {@link RenderMode}
|
||||
* @developerPreview
|
||||
*/
|
||||
export interface ServerRouteClient extends ServerRouteCommon {
|
||||
/** Specifies that the route uses Client-Side Rendering (CSR) mode. */
|
||||
@ -111,7 +105,6 @@ export interface ServerRouteClient extends ServerRouteCommon {
|
||||
/**
|
||||
* A server route that uses Static Site Generation (SSG) mode.
|
||||
* @see {@link RenderMode}
|
||||
* @developerPreview
|
||||
*/
|
||||
export interface ServerRoutePrerender extends Omit<ServerRouteCommon, 'status'> {
|
||||
/** Specifies that the route uses Static Site Generation (SSG) mode. */
|
||||
@ -126,7 +119,6 @@ export interface ServerRoutePrerender extends Omit<ServerRouteCommon, 'status'>
|
||||
* @see {@link RenderMode}
|
||||
* @see {@link ServerRoutePrerender}
|
||||
* @see {@link PrerenderFallback}
|
||||
* @developerPreview
|
||||
*/
|
||||
export interface ServerRoutePrerenderWithParams extends Omit<ServerRoutePrerender, 'fallback'> {
|
||||
/**
|
||||
@ -171,7 +163,6 @@ export interface ServerRoutePrerenderWithParams extends Omit<ServerRoutePrerende
|
||||
/**
|
||||
* A server route that uses Server-Side Rendering (SSR) mode.
|
||||
* @see {@link RenderMode}
|
||||
* @developerPreview
|
||||
*/
|
||||
export interface ServerRouteServer extends ServerRouteCommon {
|
||||
/** Specifies that the route uses Server-Side Rendering (SSR) mode. */
|
||||
@ -181,7 +172,6 @@ export interface ServerRouteServer extends ServerRouteCommon {
|
||||
/**
|
||||
* Server route configuration.
|
||||
* @see {@link provideServerRouting}
|
||||
* @developerPreview
|
||||
*/
|
||||
export type ServerRoute =
|
||||
| ServerRouteClient
|
||||
@ -221,7 +211,6 @@ export const SERVER_ROUTES_CONFIG = new InjectionToken<ServerRoutesConfig>('SERV
|
||||
*
|
||||
* @see {@link ServerRoute}
|
||||
* @see {@link withAppShell}
|
||||
* @developerPreview
|
||||
*/
|
||||
export function provideServerRouting(
|
||||
routes: ServerRoute[],
|
||||
|
Loading…
x
Reference in New Issue
Block a user