diff --git a/templates/Angular2Spa/ClientApp/boot-server.ts b/templates/Angular2Spa/ClientApp/boot-server.ts index 7ae129a..c29916f 100644 --- a/templates/Angular2Spa/ClientApp/boot-server.ts +++ b/templates/Angular2Spa/ClientApp/boot-server.ts @@ -1,5 +1,6 @@ import 'angular2-universal-polyfills'; import 'zone.js'; +import { createServerRenderer, RenderResult } from 'aspnet-prerendering'; import { enableProdMode } from '@angular/core'; import { platformNodeDynamic } from 'angular2-universal'; import { AppModule } from './app/app.module'; @@ -7,8 +8,8 @@ import { AppModule } from './app/app.module'; enableProdMode(); const platform = platformNodeDynamic(); -export default function (params: any) : Promise<{ html: string, globals?: any }> { - return new Promise((resolve, reject) => { +export default createServerRenderer(params => { + return new Promise((resolve, reject) => { const requestZone = Zone.current.fork({ name: 'angular-universal request', properties: { @@ -29,4 +30,4 @@ export default function (params: any) : Promise<{ html: string, globals?: any }> resolve({ html: html }); }, reject); }); -} +}); diff --git a/templates/Angular2Spa/package.json b/templates/Angular2Spa/package.json index b0987c9..26c2298 100644 --- a/templates/Angular2Spa/package.json +++ b/templates/Angular2Spa/package.json @@ -19,7 +19,7 @@ "angular2-template-loader": "^0.6.0", "angular2-universal": "~2.0.11", "angular2-universal-polyfills": "~2.0.11", - "aspnet-prerendering": "^1.0.7", + "aspnet-prerendering": "^2.0.0", "aspnet-webpack": "^1.0.17", "bootstrap": "^3.3.7", "css": "^2.2.1", diff --git a/templates/ReactReduxSpa/ClientApp/boot-server.tsx b/templates/ReactReduxSpa/ClientApp/boot-server.tsx index 62aefcf..1bb8842 100644 --- a/templates/ReactReduxSpa/ClientApp/boot-server.tsx +++ b/templates/ReactReduxSpa/ClientApp/boot-server.tsx @@ -3,12 +3,12 @@ import { Provider } from 'react-redux'; import { renderToString } from 'react-dom/server'; import { match, RouterContext } from 'react-router'; import createMemoryHistory from 'history/lib/createMemoryHistory'; +import { createServerRenderer, RenderResult } from 'aspnet-prerendering'; import routes from './routes'; import configureStore from './configureStore'; -type BootResult = { html?: string, globals?: { [key: string]: any }, redirectUrl?: string}; -export default function (params: any): Promise<{ html: string }> { - return new Promise((resolve, reject) => { +export default createServerRenderer(params => { + return new Promise((resolve, reject) => { // Match the incoming request against the list of client-side routes match({ routes, location: params.location }, (error, redirectLocation, renderProps: any) => { if (error) { @@ -47,4 +47,4 @@ export default function (params: any): Promise<{ html: string }> { }, reject); // Also propagate any errors back into the host application }); }); -} +}); diff --git a/templates/ReactReduxSpa/package.json b/templates/ReactReduxSpa/package.json index a5a1888..59d95d1 100644 --- a/templates/ReactReduxSpa/package.json +++ b/templates/ReactReduxSpa/package.json @@ -14,7 +14,7 @@ "@types/webpack": "^1.12.35", "@types/webpack-env": "^1.12.1", "@types/whatwg-fetch": "0.0.28", - "aspnet-prerendering": "^1.0.7", + "aspnet-prerendering": "^2.0.0", "aspnet-webpack": "^1.0.17", "aspnet-webpack-react": "^1.0.2", "babel-core": "^6.5.2",