Skip to content

Low level configurable custom SSR Api (similar to CommonEngine) #33599

Description

@eze-nonso

Command

new

Description

There is need for a low-level configurable engine for server-side-rendering. Custom setups such as Monorepo applications, and deciding render mode at runtime are not currently supported by AngularNodeAppEngine.

In the past, the CommonEngine had this role. But with V22 deprecation, this would soon become impossible.

This configurable engine would cater for more complex setups - for example a server designed to dynamically bootstrap and render one of several angular applications based on the request.

Describe the solution you'd like

Here, the angularNodeAppEngine abstracts the logic of selecting which application to render, and dependent static files.

const angularApp = new AngularNodeAppEngine();

app.use('*', (req, res, next) => {
  angularApp
    .handle(req)
    .then((response) => {
      if (response) {
        writeResponseToNodeResponse(response, res);
      } else {
        next(); // Pass control to the next middleware
      }
    })
    .catch(next);
});

With the now deprecated commonEngine:

commonEngine
      .render({
        bootstrap: AppServerModule,
        documentFilePath: indexHtml,
        url: `${protocol}://${headers.host}${originalUrl}`,
        publicPath: distFolder,
        providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }],
      })
      .then((html) => res.send(html))
      .catch((err) => next(err));

We need such a user-configurable API that allows developers more control over the node server. I should be able to for instance, configure this server as a client-facing server deployable however I choose, even in a multi-application environment

Describe alternatives you've considered

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions