7 Commits

Author SHA1 Message Date
Alan Agius
18b6aea397 refactor(@angular/ssr): Add RequestHandlerFunction and NodeRequestHandlerFunction to public API
These additions are necessary to ensure their inclusion in adev.
2024-11-05 19:39:13 +01:00
Alan Agius
92209dd2e9 feat(@angular/ssr): add createRequestHandler and createNodeRequestHandler utilities
Introduced the `createRequestHandler` and `createNodeRequestHandler` utilities to expose middleware functions from the `server.ts` entry point for use with Vite.
This provides flexibility in integrating different server frameworks, including Express, Hono, and Fastify, with Angular SSR.

Examples:

**Express**
```ts
export default createNodeRequestHandler(app);
```

**Nest.js**
```ts
const app = await NestFactory.create(AppModule);
export default createNodeRequestHandler(app);
```

**Hono**
```ts
const app = new Hono();
export default createRequestHandler(app.fetch);
```

**Fastify**
```ts
export default createNodeRequestHandler(async (req, res) => {
  await app.ready();
  app.server.emit('request', req, res);
});
```
2024-09-23 22:34:55 +02:00
Alan Agius
f346ee8a88 feat(@angular/ssr): add isMainModule function
Adds a new function `isMainModule` that checks if the current module is the main entry point of the application.

This is useful to ensure that server listener handlers are only registered when the module is executed directly and not when it's imported as a dependency such as the dev-server. This prevents potential issues with multiple listeners being registered unintentionally.
2024-09-17 16:41:00 +02:00
Alan Agius
7d9ce246a3 refactor(@angular/ssr): remove singleton helpers
This commit removes the singleton helpers and instead exposes the
classes directly.
2024-09-06 07:13:04 +02:00
Alan Agius
576ff604cd feat(@angular/ssr): introduce AngularNodeAppEngine API for Node.js integration
Expose a variant of `AngularAppEngine` tailored for Node.js. These additions streamline the process by minimizing boilerplate code and eliminate the need for users to call `createWebRequestFromNodeRequest` before invoking the render method.
2024-09-06 07:13:04 +02:00
Alan Agius
455b5700c2 feat(@angular/ssr): expose writeResponseToNodeResponse and createWebRequestFromNodeRequest in public API
These additions enhance server-side rendering capabilities by providing more flexibility in handling web requests and responses within Node.js environments.
2024-08-30 09:49:24 -07:00
Alan Agius
4b09887a9c feat(@angular/ssr): move CommonEngine API to /node entry-point
Refactored the `CommonEngine` API import path to remove Node.js dependencies from the `@angular/ssr` main entry-point.

BREAKING CHANGE:

The `CommonEngine` API now needs to be imported from `@angular/ssr/node`.

**Before**
```ts
import { CommonEngine } from '@angular/ssr';
```

**After**
```ts
import { CommonEngine } from '@angular/ssr/node';
```
2024-08-27 08:57:37 +02:00