Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function site (
serverModuleFactory: Type<{}>,
document: string,
url: string = '/',
config?: string | SiteGenConfig
) {
// if (typeof config === 'string') {
// config = require.resolve(path.join(process.cwd(), config))
// }
// console.log('config here ', config)
return renderModule(
serverModuleFactory,
{document, url}
)
}
export default createServerRenderer(params => {
const { AppServerModule, AppServerModuleNgFactory, LAZY_MODULE_MAP } = (module as any).exports;
const options = {
document: params.data.originalHtml,
url: params.url,
extraProviders: [
provideModuleMap(LAZY_MODULE_MAP),
{ provide: APP_BASE_HREF, useValue: params.baseUrl },
{ provide: 'BASE_URL', useValue: params.origin + params.baseUrl },
{ provide: COOKIES, useValue: params.data.cookies }
]
};
const renderPromise = AppServerModuleNgFactory
? /* AoT */ renderModuleFactory(AppServerModuleNgFactory, options)
: /* dev */ renderModule(AppServerModule, options);
return renderPromise.then(html => {
return {
html
};
});
});
export default createServerRenderer(params => {
const { AppServerModule, AppServerModuleNgFactory, LAZY_MODULE_MAP } = (module as any).exports;
const options = {
document: params.data.originalHtml,
url: params.url,
extraProviders: [
provideModuleMap(LAZY_MODULE_MAP),
{ provide: APP_BASE_HREF, useValue: params.baseUrl },
{ provide: 'BASE_URL', useValue: params.origin + params.baseUrl }
]
};
const renderPromise = AppServerModuleNgFactory
? /* AoT */ renderModuleFactory(AppServerModuleNgFactory, options)
: /* dev */ renderModule(AppServerModule, options);
return renderPromise.then(html => ({ html }));
});
const options = {
document: params.data.originalHtml,
url: params.url,
extraProviders: [
provideModuleMap(LAZY_MODULE_MAP),
{ provide: APP_BASE_HREF, useValue: params.baseUrl },
{ provide: "BASE_URL", useValue: params.origin + params.baseUrl }
]
};
// Bypass ssr api call cert warnings in development
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
const renderPromise = AppServerModuleNgFactory
? /* AoT */ renderModuleFactory(AppServerModuleNgFactory, options)
: /* dev */ renderModule(AppServerModule, options);
return renderPromise.then(html => ({ html }));
});
LAZY_MODULE_MAP,
} = (module as any).exports;
const options = {
document: params.data.originalHtml,
url: params.url,
extraProviders: [
provideModuleMap(LAZY_MODULE_MAP),
{ provide: APP_BASE_HREF, useValue: params.baseUrl },
{ provide: 'BASE_URL', useValue: params.origin + params.baseUrl },
],
};
const renderPromise = AppServerModuleNgFactory
? /* AoT */ renderModuleFactory(AppServerModuleNgFactory, options)
: /* dev */ renderModule(AppServerModule, options);
return renderPromise.then((html) => ({ html }));
});
import 'core-js/proposals/reflect-metadata';
import {platformDynamicServer, renderModule} from '@angular/platform-server';
import {AppModule} from './app.module';
AppModule.testProp = 'testing';
platformDynamicServer().bootstrapModule(AppModule);
renderModule(AppModule, {
document: '',
url: '/'
});
import 'core-js/es7/reflect';
import {platformDynamicServer, renderModule} from '@angular/platform-server';
import {AppModule} from './app.module';
AppModule.testProp = 'testing';
platformDynamicServer().bootstrapModule(AppModule);
renderModule(AppModule, {
document: '',
url: '/'
});
.mergeMap(() => renderModule(appServerModule, { url, document }))
.map(html => ({ url, html: minifyHtml(html) }));
function renderPage(url: string, document: string) {
return renderModule(appRendererModule, { url, document })
.then(html => production ? minifyHtml(html) : html)
.then(html => {
const urlWithFilename = url.endsWith('/') ? `${url}index.html` : `${url}.html`;
files.push({ path: urlWithFilename.substr(1), contents: html });
});
}
function renderPage(url: string, document: string) {
const visitors = [
removeInnerHtmlAttributes
];
return renderModule(appRendererModule, { url, document })
.then(html => transformHtml(html, visitors))
.then(html => production ? minifyHtml(html) : html)
.then(html => {
const urlWithFilename = url.endsWith('/') ? `${url}index.html` : `${url}.html`;
files.push({ path: urlWithFilename.substr(1), contents: html });
});
}