-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@angular/ssr): add server routing configuration API
This commit introduces a new server routing configuration API, as discussed in RFC angular/angular#56785. The new API provides several enhancements: ```ts const serverRoutes: ServerRoute[] = [ { path: '/error', renderMode: RenderMode.Server, status: 404, headers: { 'Cache-Control': 'no-cache' } } ]; ``` ```ts const serverRoutes: ServerRoute[] = [ { path: '/product/:id', renderMode: RenderMode.Prerender, async getPrerenderPaths() { const dataService = inject(ProductService); const ids = await dataService.getIds(); // Assuming this returns ['1', '2', '3'] return ids.map(id => ({ id })); // Generates paths like: [{ id: '1' }, { id: '2' }, { id: '3' }] } } ]; ``` ```ts const serverRoutes: ServerRoute[] = [ { path: '/product/:id', renderMode: RenderMode.Prerender, fallback: PrerenderFallback.Server, // Can be Server, Client, or None async getPrerenderPaths() { } } ]; ``` ```ts const serverRoutes: ServerRoute[] = [ { path: '/product/:id', renderMode: RenderMode.Server, }, { path: '/error', renderMode: RenderMode.Client, }, { path: '/**', renderMode: RenderMode.Prerender, }, ]; ``` These additions aim to provide greater flexibility and control over server-side rendering configurations and prerendering behaviors.
- Loading branch information
1 parent
793f6a0
commit d66aaa3
Showing
27 changed files
with
868 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## API Report File for "@angular/devkit-repo" | ||
|
||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
```ts | ||
|
||
// @public | ||
export interface ServerRouteAppShell extends Omit<ServerRouteCommon, 'headers' | 'status'> { | ||
renderMode: RenderMode.AppShell; | ||
} | ||
|
||
// @public | ||
export interface ServerRouteClient extends ServerRouteCommon { | ||
renderMode: RenderMode.Client; | ||
} | ||
|
||
// @public | ||
export interface ServerRouteCommon { | ||
headers?: Record<string, string>; | ||
path: string; | ||
status?: number; | ||
} | ||
|
||
// @public | ||
export interface ServerRoutePrerender extends Omit<ServerRouteCommon, 'status'> { | ||
fallback?: never; | ||
renderMode: RenderMode.Prerender; | ||
} | ||
|
||
// @public | ||
export interface ServerRoutePrerenderWithParams extends Omit<ServerRoutePrerender, 'fallback'> { | ||
fallback?: PrerenderFallback; | ||
getPrerenderParams: () => Promise<Record<string, string>[]>; | ||
} | ||
|
||
// @public | ||
export interface ServerRouteServer extends ServerRouteCommon { | ||
renderMode: RenderMode.Server; | ||
} | ||
|
||
// (No @packageDocumentation comment for this package) | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
|
||
// This file exports symbols that are not part of the public API but are | ||
// dependencies of public API symbols. Including them here ensures they | ||
// are tracked in the API golden file, preventing accidental breaking changes. | ||
|
||
export type { | ||
ServerRouteAppShell, | ||
ServerRouteClient, | ||
ServerRoutePrerender, | ||
ServerRoutePrerenderWithParams, | ||
ServerRouteServer, | ||
ServerRouteCommon, | ||
} from './src/routes/route-config'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.