File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed
goldens/public-api/angular/ssr/node
packages/angular/ssr/node Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ export interface CommonEngineRenderOptions {
46
46
// @public
47
47
export function createWebRequestFromNodeRequest(nodeRequest : IncomingMessage ): Request ;
48
48
49
+ // @public
50
+ export function defineNodeNextHandler<T = NextHandleFunction >(handler : T ): T ;
51
+
49
52
// @public
50
53
export function isMainModule(url : string ): boolean ;
51
54
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export {
14
14
15
15
export { AngularNodeAppEngine } from './src/app-engine' ;
16
16
17
+ export { defineNodeNextHandler } from './src/handler' ;
17
18
export { writeResponseToNodeResponse } from './src/response' ;
18
19
export { createWebRequestFromNodeRequest } from './src/request' ;
19
20
export { isMainModule } from './src/module' ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+
9
+ import type { IncomingMessage , ServerResponse } from 'node:http' ;
10
+
11
+ /**
12
+ * Represents a middleware function for handling HTTP requests in a Node.js environment.
13
+ *
14
+ * @param req - The incoming HTTP request object.
15
+ * @param res - The outgoing HTTP response object.
16
+ * @param next - A callback function that signals the completion of the middleware or forwards the error if provided.
17
+ *
18
+ * @returns A Promise that resolves to void or simply void. The handler can be asynchronous.
19
+ */
20
+ type NextHandleFunction = (
21
+ req : IncomingMessage ,
22
+ res : ServerResponse ,
23
+ next : ( err ?: unknown ) => void ,
24
+ ) => Promise < void > | void ;
25
+
26
+ /**
27
+ * Attaches metadata to the handler function to mark it as a special handler for Node.js environments.
28
+ *
29
+ * @typeParam T - The type of the handler function, which defaults to `NextHandleFunction`.
30
+ * @param handler - The handler function to be defined and annotated.
31
+ * @returns The same handler function passed as an argument, with metadata attached.
32
+ * @developerPreview
33
+ */
34
+ export function defineNodeNextHandler < T = NextHandleFunction > ( handler : T ) : T {
35
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
+ ( handler as any ) [ '__ng_node_next_handler__' ] = true ;
37
+
38
+ return handler ;
39
+ }
You can’t perform that action at this time.
0 commit comments