export async function ngHapiEngine()

in modules/hapi-engine/src/main.ts [34:56]


export async function ngHapiEngine(options: Readonly<RenderOptions>): Promise<string> {
  const req = options.req;
  if (req.raw.req.url === undefined) {
    throw new Error('url is undefined');
  }

  const protocol = req.server.info.protocol;
  const filePath = req.raw.req.url as string;

  const renderOptions: RenderOptions = { ...options };

  const moduleOrFactory = options.bootstrap;

  if (!moduleOrFactory) {
    throw new Error('You must pass in a NgModule or NgModuleFactory to be bootstrapped');
  }

  renderOptions.url = options.url || `${protocol}://${req.info.host}${req.path}`;
  renderOptions.documentFilePath = renderOptions.documentFilePath || filePath;
  renderOptions.providers = [...(options.providers || []), getReqProviders(options.req)];

  return commonEngine.render(renderOptions);
}