Skip to content

Commit 455b570

Browse files
alan-agius4dgp1130
authored andcommittedAug 30, 2024·
feat(@angular/ssr): expose writeResponseToNodeResponse and createWebRequestFromNodeRequest in public API
These additions enhance server-side rendering capabilities by providing more flexibility in handling web requests and responses within Node.js environments.
1 parent dd78c81 commit 455b570

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed
 

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

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
```ts
66

77
import { ApplicationRef } from '@angular/core';
8+
import type { IncomingMessage } from 'node:http';
9+
import type { ServerResponse } from 'node:http';
810
import { StaticProvider } from '@angular/core';
911
import { Type } from '@angular/core';
1012

@@ -35,6 +37,12 @@ export interface CommonEngineRenderOptions {
3537
url?: string;
3638
}
3739

40+
// @public
41+
export function createWebRequestFromNodeRequest(nodeRequest: IncomingMessage): Request;
42+
43+
// @public
44+
export function writeResponseToNodeResponse(source: Response, destination: ServerResponse): Promise<void>;
45+
3846
// (No @packageDocumentation comment for this package)
3947

4048
```

‎packages/angular/ssr/node/public_api.ts

+3
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ export {
1111
type CommonEngineRenderOptions,
1212
type CommonEngineOptions,
1313
} from './src/common-engine/common-engine';
14+
15+
export { writeResponseToNodeResponse } from './src/response';
16+
export { createWebRequestFromNodeRequest } from './src/request';

‎packages/angular/ssr/node/src/request.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type { IncomingHttpHeaders, IncomingMessage } from 'node:http';
1313
*
1414
* @param nodeRequest - The Node.js `IncomingMessage` object to convert.
1515
* @returns A Web Standard `Request` object.
16+
* @developerPreview
1617
*/
1718
export function createWebRequestFromNodeRequest(nodeRequest: IncomingMessage): Request {
1819
const { headers, method = 'GET' } = nodeRequest;

‎packages/angular/ssr/node/src/response.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type { ServerResponse } from 'node:http';
1414
* @param source - The web-standard `Response` object to stream from.
1515
* @param destination - The Node.js `ServerResponse` object to stream into.
1616
* @returns A promise that resolves once the streaming operation is complete.
17+
* @developerPreview
1718
*/
1819
export async function writeResponseToNodeResponse(
1920
source: Response,

0 commit comments

Comments
 (0)
Please sign in to comment.