Skip to content

Commit a568f19

Browse files
committed
refactor(@angular/ssr): Add RequestHandlerFunction and NodeRequestHandlerFunction to public API
These additions are necessary to ensure their inclusion in adev. (cherry picked from commit 18b6aea)
1 parent e4df756 commit a568f19

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

goldens/public-api/angular/ssr/index.api.md

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export enum RenderMode {
3333
Server = 1
3434
}
3535

36+
// @public
37+
export type RequestHandlerFunction = (request: Request) => Promise<Response | null> | null | Response;
38+
3639
// @public
3740
export type ServerRoute = ServerRouteAppShell | ServerRouteClient | ServerRoutePrerender | ServerRoutePrerenderWithParams | ServerRouteServer;
3841

goldens/public-api/angular/ssr/node/index.api.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,17 @@ export interface CommonEngineRenderOptions {
4343
}
4444

4545
// @public
46-
export function createNodeRequestHandler<T extends RequestHandlerFunction>(handler: T): T;
46+
export function createNodeRequestHandler<T extends NodeRequestHandlerFunction>(handler: T): T;
4747

4848
// @public
4949
export function createWebRequestFromNodeRequest(nodeRequest: IncomingMessage): Request;
5050

5151
// @public
5252
export function isMainModule(url: string): boolean;
5353

54+
// @public
55+
export type NodeRequestHandlerFunction = (req: IncomingMessage, res: ServerResponse, next: (err?: unknown) => void) => Promise<void> | void;
56+
5457
// @public
5558
export function writeResponseToNodeResponse(source: Response, destination: ServerResponse): Promise<void>;
5659

packages/angular/ssr/node/public_api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export {
1414

1515
export { AngularNodeAppEngine } from './src/app-engine';
1616

17-
export { createNodeRequestHandler } from './src/handler';
17+
export { createNodeRequestHandler, type NodeRequestHandlerFunction } from './src/handler';
1818
export { writeResponseToNodeResponse } from './src/response';
1919
export { createWebRequestFromNodeRequest } from './src/request';
2020
export { isMainModule } from './src/module';

packages/angular/ssr/node/src/handler.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import type { IncomingMessage, ServerResponse } from 'node:http';
1616
* @param next - A callback function that signals the completion of the middleware or forwards the error if provided.
1717
*
1818
* @returns A Promise that resolves to void or simply void. The handler can be asynchronous.
19+
* @developerPreview
1920
*/
20-
type RequestHandlerFunction = (
21+
export type NodeRequestHandlerFunction = (
2122
req: IncomingMessage,
2223
res: ServerResponse,
2324
next: (err?: unknown) => void,
@@ -67,7 +68,7 @@ type RequestHandlerFunction = (
6768
* ```
6869
* @developerPreview
6970
*/
70-
export function createNodeRequestHandler<T extends RequestHandlerFunction>(handler: T): T {
71+
export function createNodeRequestHandler<T extends NodeRequestHandlerFunction>(handler: T): T {
7172
(handler as T & { __ng_node_request_handler__?: boolean })['__ng_node_request_handler__'] = true;
7273

7374
return handler;

packages/angular/ssr/public_api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
export * from './private_export';
1010

1111
export { AngularAppEngine } from './src/app-engine';
12-
export { createRequestHandler } from './src/handler';
12+
export { createRequestHandler, type RequestHandlerFunction } from './src/handler';
1313

1414
export {
1515
type PrerenderFallback,

packages/angular/ssr/src/handler.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
* @param request - The incoming HTTP request object.
1313
* @returns A Promise resolving to a `Response` object, `null`, or directly a `Response`,
1414
* supporting both synchronous and asynchronous handling.
15+
* @developerPreview
1516
*/
16-
type RequestHandlerFunction = (request: Request) => Promise<Response | null> | null | Response;
17+
export type RequestHandlerFunction = (
18+
request: Request,
19+
) => Promise<Response | null> | null | Response;
1720

1821
/**
1922
* Annotates a request handler function with metadata, marking it as a special

0 commit comments

Comments
 (0)