Skip to content

Commit

Permalink
feat(@angular/ssr): expose writeResponseToNodeResponse and `createW…
Browse files Browse the repository at this point in the history
…ebRequestFromNodeRequest` in public API

These additions enhance server-side rendering capabilities by providing more flexibility in handling web requests and responses within Node.js environments.
  • Loading branch information
alan-agius4 authored and dgp1130 committed Aug 30, 2024
1 parent dd78c81 commit 455b570
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions goldens/public-api/angular/ssr/node/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
```ts

import { ApplicationRef } from '@angular/core';
import type { IncomingMessage } from 'node:http';
import type { ServerResponse } from 'node:http';
import { StaticProvider } from '@angular/core';
import { Type } from '@angular/core';

Expand Down Expand Up @@ -35,6 +37,12 @@ export interface CommonEngineRenderOptions {
url?: string;
}

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

// @public
export function writeResponseToNodeResponse(source: Response, destination: ServerResponse): Promise<void>;

// (No @packageDocumentation comment for this package)

```
3 changes: 3 additions & 0 deletions packages/angular/ssr/node/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ export {
type CommonEngineRenderOptions,
type CommonEngineOptions,
} from './src/common-engine/common-engine';

export { writeResponseToNodeResponse } from './src/response';
export { createWebRequestFromNodeRequest } from './src/request';
1 change: 1 addition & 0 deletions packages/angular/ssr/node/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { IncomingHttpHeaders, IncomingMessage } from 'node:http';
*
* @param nodeRequest - The Node.js `IncomingMessage` object to convert.
* @returns A Web Standard `Request` object.
* @developerPreview
*/
export function createWebRequestFromNodeRequest(nodeRequest: IncomingMessage): Request {
const { headers, method = 'GET' } = nodeRequest;
Expand Down
1 change: 1 addition & 0 deletions packages/angular/ssr/node/src/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { ServerResponse } from 'node:http';
* @param source - The web-standard `Response` object to stream from.
* @param destination - The Node.js `ServerResponse` object to stream into.
* @returns A promise that resolves once the streaming operation is complete.
* @developerPreview
*/
export async function writeResponseToNodeResponse(
source: Response,
Expand Down

0 comments on commit 455b570

Please sign in to comment.