Skip to content

Commit

Permalink
fix(express-engine): RenderOptions is not assignable to object
Browse files Browse the repository at this point in the history
Closes #1744
  • Loading branch information
alan-agius4 committed Jun 26, 2020
1 parent 0ebf846 commit 2dbe674
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions modules/express-engine/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,22 @@ export function ngExpressEngine(setupOptions: Readonly<NgSetupOptions>) {
const engine = new CommonEngine(setupOptions.bootstrap, setupOptions.providers);

return function (filePath: string,
options: Readonly<RenderOptions>,
options: object,
callback: (err?: Error | null, html?: string) => void) {
try {
if (!setupOptions.bootstrap && !options.bootstrap) {
const renderOptions = { ...options } as RenderOptions;
if (!setupOptions.bootstrap && !renderOptions.bootstrap) {
throw new Error('You must pass in a NgModule or NgModuleFactory to be bootstrapped');
}

const req = options.req;
const res = options.res || req.res;

const renderOptions: RenderOptions = Object.assign({}, options);
const req = renderOptions.req;
const res = renderOptions.res || req.res;

renderOptions.url =
options.url || `${req.protocol}://${(req.get('host') || '')}${req.originalUrl}`;
renderOptions.document = options.document || getDocument(filePath);
renderOptions.url || `${req.protocol}://${(req.get('host') || '')}${req.originalUrl}`;
renderOptions.document = renderOptions.document || getDocument(filePath);

renderOptions.providers = options.providers || [];
renderOptions.providers = renderOptions.providers || [];
renderOptions.providers = renderOptions.providers.concat(getReqResProviders(req, res));

engine.render(renderOptions)
Expand Down

0 comments on commit 2dbe674

Please sign in to comment.