Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
useValue: {
document: options.appSelector,
url: options.request.url
}
},
{
provide: ORIGIN_URL,
useValue: options.request.origin
}, {
provide: REQUEST,
useValue: options.request.data.request
}
]
);
const platform = platformServer(extraProviders);
getFactory(moduleOrFactory, compiler)
.then((factory: NgModuleFactory<{}>) => {
return platform.bootstrapModuleFactory(factory).then((moduleRef: NgModuleRef<{}>) => {
const state: PlatformState = moduleRef.injector.get(PlatformState);
const appRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
appRef.isStable
.filter((isStable: boolean) => isStable)
.first()
.subscribe((stable) => {
// Fire the TransferState Cache
const bootstrap = moduleRef.instance['ngOnBootstrap'];
document: options.appSelector,
url: options.request.url
}
},
{
provide: ORIGIN_URL,
useValue: options.request.origin
},
{
provide: APP_BASE_HREF,
useValue: options.request.baseUrl
}
]
);
const platform = platformServer(extraProviders);
getFactory(moduleOrFactory, compiler)
.then((factory: NgModuleFactory<{}>) => {
return platform.bootstrapModuleFactory(factory).then((moduleRef: NgModuleRef<{}>) => {
const state: PlatformState = moduleRef.injector.get(PlatformState);
const appRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
appRef.isStable
.filter((isStable: boolean) => isStable)
.first()
.subscribe((stable: any) => {
// Fire the SsrState Cache
const bootstrap = (moduleRef.instance as any)['ngOnBootstrap'];
useValue: {
document: options.appSelector,
url: options.request.url
}
},
{
provide: ORIGIN_URL,
useValue: options.request.origin
}, {
provide: REQUEST,
useValue: options.request.data.request
}
]
);
const platform = platformServer(extraProviders);
getFactory(moduleOrFactory, compiler)
.then((factory: NgModuleFactory<{}>) => {
return platform.bootstrapModuleFactory(factory).then((moduleRef: NgModuleRef<{}>) => {
const state: PlatformState = moduleRef.injector.get(PlatformState);
const appRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
appRef.isStable
.filter((isStable: boolean) => isStable)
.first()
.subscribe((stable) => {
// Fire the TransferState Cache
const bootstrap = moduleRef.instance['ngOnBootstrap'];
export function lsRoutes(
serverFactory: NgModuleFactory,
lazyModuleMap?: any
) {
const ngZone = new NgZone({ enableLongStackTrace: false });
const rootInjector = Injector.create(
[
{ provide: NgZone, useValue: ngZone },
provideModuleMap(lazyModuleMap)
],
platformServer().injector
);
const moduleRef = serverFactory.create(rootInjector);
loader = moduleRef.injector.get(NgModuleFactoryLoader);
return Promise.all(createModule(serverFactory, rootInjector))
.then(routes => {
return flattenArray(flattenRouteToPath(routes));
});
}
function getDoc(filePath: string, url: string): Observable {
const index = fs.readFileSync(filePath).toString();
const platform =
platformServer([{ provide: INITIAL_CONFIG, useValue: { document: index, url: url } }]);
return Observable.fromPromise(platform.bootstrapModuleFactory(ServerAppModuleNgFactory))
.switchMap((moduleRef) => {
const applicationRef: ApplicationRef = moduleRef.injector.get(ApplicationRef);
return applicationRef.isStable;
})
.first((stable) => stable === true)
.map(() => platform.injector.get(PlatformState).renderToString())
.finally(() => platform.destroy());
}
protected async bootstrap(rootModule: any) {
platformServer().bootstrapModuleFactory(rootModule);
}
}