open-index/open-npm huggingface dataset:
npm package: @nguniversal/common
Description: Angular Universal common utilities
Latest version: 16.2.0

# Angular Universal Common Module

This is the common Angular Universal module that is common across server-side rendering app
irrespective of the rendering engine.

The package can be installed using:

`npm install @nguniversal/common --save`

## TransferHttpCacheModule

Moved to [/docs/transfer-http.md](https://github.com/angular/universal/tree/main/docs/transfer-http.md)
npm package: @nguniversal/express-engine
Description: Express Engine for running Server Angular Apps
Latest version: 16.2.0

# Angular Express Engine

This is an Express Engine for running Angular Apps on the server for server side rendering.

## Usage

`npm install @nguniversal/express-engine --save`

To use it, set the engine and then route requests to it

```ts
import express from 'express';
import { ngExpressEngine } from '@nguniversal/express-engine';

const app = express();

// Set the engine
app.engine(
  'html',
  ngExpressEngine({
    bootstrap: ServerAppModule, // Give it a module to bootstrap
  }),
);

app.set('view engine', 'html');

app.get('/**/*', (req: Request, res: Response) => {
  res.render('../dist/index', {
    req,
    res,
  });
});
```

## Configuring the URL and Document

It is possible to override the default URL and document fetched when the rendering engine
is called. To do so, simply pass in a `url` and/or `document` string to the renderer as follows:

```ts
app.get('/**/*', (req: Request, res: Response) => {
  let url = 'http://someurl.com';
  let doc = '<html><head><title>New doc</title></head></html>';
  res.render('../dist/index', {
    req,
    res,
    url,
    document: doc,
  });
});
```

## Extra Providers

Extra Providers can be provided either on engine setup

```ts
app.engine(
  'html',
  ngExpressEngine({
    bootstrap: ServerAppModule,
    providers: [ServerService],
  }),
);
```

## Advanced Usage

### Request based Bootstrap

The Bootstrap module as well as more providers can be passed on request

```ts
app.get('/**/*', (req: Request, res: Response) => {
  res.render('../dist/index', {
    req,
    res,
    bootstrap: OtherServerAppModule,
    providers: [OtherServerService],
  });
});
```

### Using the Request and Response

The Request and Response objects are injected into the app via injection tokens.
You can access them by @Inject

```ts
import { Request } from 'express';
import { REQUEST } from '@nguniversal/express-engine/tokens';

@Injectable()
export class RequestService {
  constructor(@Inject(REQUEST) private request: Request) {}
}
```

If your app runs on the client side too, you will have to provide your own versions of these in the client app.

### Using a Custom Callback

You can also use a custom callback to better handle your errors

```ts
app.get('/**/*', (req: Request, res: Response) => {
  res.render(
    '../dist/index',
    {
      req,
      res,
    },
    (err: Error, html: string) => {
      res.status(html ? 200 : 500).send(html || err.message);
    },
  );
});
```
npm package: @nguniversal/hapi-engine
Description: Hapi Engine for running Server Angular Apps
Latest version: 13.1.1
Deprecated: @nguniversal/hapi-engine is deprecated and will not receive future updates. Use @nguniversal/common instead.

# Angular Hapi Engine

This is a Hapi Engine for running Angular Apps on the server for server side rendering.

## Deprecated

This package has been deprecated. Please use [`@nguniversal/common`](../common/README.md) instead.

## Usage

`npm install @nguniversal/hapi-engine --save`

To use it, set the engine and then route requests to it

```ts
import { Request, Server } from 'hapi';
import { ngHapiEngine } from '@nguniversal/hapi-engine';

const server = new Server();
server.connection({
  host: 'localhost',
  port: 8000,
});

server.route({
  method: 'GET',
  path: '/{path*}',
  handler: (req: Request) => ngHapiEngine({ req, bootstrap: ServerAppModule }),
});
```

## Configuring the URL and Document

It is possible to override the default URL and document fetched when the rendering engine
is called. To do so, simply pass in a `url` and/or `document` string to the renderer as follows:

```ts
server.route({
  method: 'GET',
  path: '/{path*}',
  handler: (req: Request) => {
    const url = 'http://someurl.com';
    const document = '<html><head><title>New doc</title></head></html>';
    return ngHapiEngine({
      req,
      url,
      document,
    });
  },
});
```

## Extra Providers

Extra Providers can be provided either on engine setup

```ts
const hapiEngine = ngHapiEngine({
  bootstrap: ServerAppModule,
  providers: [ServerService],
});
```

## Advanced Usage

### Request based Bootstrap

The Bootstrap module as well as more providers can be passed on request

```ts
server.route({
  method: 'GET',
  path: '/{path*}',
  handler: (req: Request) =>
    ngHapiEngine({
      bootstrap: OtherServerAppModule,
      providers: [OtherServerService],
      req,
    }),
});
```

### Using the Request and Response

The Request and Response objects are injected into the app via injection tokens.
You can access them by `@Inject`

```ts
import { Request } from 'hapi';
import { REQUEST } from '@nguniversal/hapi-engine/tokens';

@Injectable()
export class RequestService {
  constructor(@Inject(REQUEST) private request: Request) {}
}
```

If your app runs on the client side too, you will have to provide your own versions of these in the client app.
npm package: @nguniversal/module-map-ngfactory-loader
Description: NgFactoryLoader which uses a Map to load ngfactories without lazy loading
Latest version: 8.2.6
Deprecated: The string form of `loadChildren` is deprecated, this package is part of its implementation and is no longer needed if not using string form lazy loading. See: https://angular.io/api/router/LoadChildren for more details.

# Module Map NgFactory Loader

This is a NgFactory Loader which uses a map of modules instead of resolving modules lazily.

This is useful when executing in node because lazy loading serves no purpose

## Usage with `@angular/cli`

`npm install @nguniversal/module-map-ngfactory-loader --save`

`@angular/cli` will generate `LAZY_MODULE_MAP` in its main output bundle if you put app.platform = 'server'.

```ts
const { provideModuleMap } = require('@nguniversal/module-map-ngfactory-loader');
const { AppModuleNgFactory, LAZY_MODULE_MAP } = require('main.bundle.js');

renderModuleFactory(AppModuleNgFactory, {
  document: '<app-root></app-root>',
  url: '/',
  extraProviders: [
    provideModuleMap(LAZY_MODULE_MAP)
  ]
})
```

Add `ModuleMapLoaderModule` to your server module

```ts
import {ModuleMapLoaderModule} from '@nguniversal/module-map-ngfactory-loader';

@NgModule({
  imports: [
    AppModule,
    ServerModule,
    ModuleMapLoaderModule
  ],
  bootstrap: [AppComponent],
})
export class AppServerModule {}
```
npm package: @nguniversal/socket-engine
Description: Socket Engine for running Server Angular Apps
Latest version: 13.1.1
Deprecated: @nguniversal/socket-engine is deprecated and will not receive future updates. Use @nguniversal/common instead.

# Angular Universal Socket Engine

Framework and Platform agnostic Angular Universal rendering.

## Deprecated

This package has been deprecated. Please use [`@nguniversal/common`](../common/README.md) instead.

## Usage Server

`npm install @nguniversal/socket-engine @nguniversal/common --save`

```js
const socketEngine = require('@nguniversal/socket-engine');

// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main');

socketEngine.startSocketEngine(AppServerModuleNgFactory);
```

This will the socket engine which internally hosts a TCP Socket server.  
The default port is `9090` and host of `localhost`
You may want to leave this as a plain `.js` file since it is so simple and to make deploying it easier, but it can be easily transpiled from Typescript.

## Usage Client

Your client can be whatever language, framework or platform you like.  
As long as it can connect to a TCP Socket (which all frameworks can) then you're good to go.

This example will use JS for simplicity

```typescript
import * as net from 'net';

const client = net.createConnection(9090, 'localhost', () => {
  console.log('connected to SSR server');
});

client.on('data', (data) => {
  const res = JSON.parse(data.toString()) as SocketEngineResponse;
  expect(res.id).toEqual(1);
  expect(res.html).toEqual(template);
  server.close();
  done();
});

const renderOptions = {
  id: 1,
  url: '/path',
  document: '<app-root></app-root>',
} as SocketEngineRenderOptions;
client.write(JSON.stringify(renderOptions));
```
npm package: @nguraijs/core
Description: Lightweight and customizable tokenizer.
Author: NOuSantx
Latest version: 0.2.0

# `@nguraijs/core`

A very lightweight tokenizer library.

## Installation

```bash
npm i @nguraijs/core
```

## Usage Example

```javascript
import { Ngurai } from '@nguraijs/core'

const urx = new Ngurai({
  comments: [{ prefix: '//' }, { prefix: '/*', suffix: '*/' }],
  tokens: {
    keyword: ['const', 'console'],
    punctuation: ['=', ';', '.', '(', ')'],
    global: ['log']
  }
})

urx.process(`const data = /*@__PURE__*/ 56;\nconsole.log(data); // this is comment`)
```

Output :

```javascript
;[
  [
    { type: 'keyword', value: 'const', position: 0 },
    { type: 'space', value: ' ', position: 5 },
    { type: 'identifier', value: 'data', position: 6 },
    { type: 'space', value: ' ', position: 10 },
    { type: 'punctuation', value: '=', position: 11 },
    { type: 'space', value: ' ', position: 12 },
    { type: 'comment', value: '/*@__PURE__*/', position: 13 },
    { type: 'space', value: ' ', position: 26 },
    { type: 'number', value: '56', position: 27 },
    { type: 'punctuation', value: ';', position: 29 }
  ],
  [
    { type: 'keyword', value: 'console', position: 0 },
    { type: 'punctuation', value: '.', position: 7 },
    { type: 'globals', value: 'log', position: 8 },
    { type: 'punctuation', value: '(', position: 11 },
    { type: 'identifier', value: 'data', position: 12 },
    { type: 'punctuation', value: ')', position: 16 },
    { type: 'punctuation', value: ';', position: 17 },
    { type: 'space', value: ' ', position: 18 },
    { type: 'comment', value: '// this is comment', position: 19 }
  ]
]
```

## LICENSE

MIT © 2025-present NguraiJS Team