# App Host

### Imports

{% tabs %}
{% tab title="Service" %}

```typescript
import { AppHostService } from 'niro-health';
```

{% endtab %}

{% tab title="Module" %}

```typescript
import { AppHostModule } from 'niro-health';
```

{% endtab %}

{% tab title="Interface" %}

```typescript
import type { IAppHostService } from 'niro-health';
```

{% endtab %}
{% endtabs %}

### Method of Use

To use this module, you need to import it at least once in your main module. This way, you can inject it into the remaining modules without having to import it again.

In the example below, I am importing the module and also the service.

{% code overflow="wrap" %}

```typescript
import { Module } from '@nestjs/common';
import { AppHostModule, AppHostService } from 'niro-health';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  imports: [AppHostModule],
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: 'IAppHostService',
      useClass: AppHostService,
    },
  ],
})
export class AppModule {}
```

{% endcode %}

Injecting the module into our service.

```typescript
import { Inject, Injectable } from '@nestjs/common';
import type { IAppHostService } from 'niro-health';

@Injectable()
export class AppService {
  constructor(
    @Inject('IAppHostService')
    private readonly appHostService: IAppHostService,
  ) {}

  getUrl() {
    return this.appHostService.getUrl();
  }
}
```

### Global

This module is global, you only need to import it once in the main module. After that, you can inject the service without importing it in the other modules.

{% hint style="info" %}
But remember to include AppHostService in the list of providers for the module where you want to inject it.
{% endhint %}

### Without dependencies

You won't need to connect the pieces with any other module.

### Properties

<table><thead><tr><th width="320">Property</th><th width="108" align="center">Scope</th><th>Description</th></tr></thead><tbody><tr><td><code>app</code></td><td align="center"><code>static</code></td><td><code>The NestJS application instance.</code></td></tr></tbody></table>

### Methods

<table><thead><tr><th>Method</th><th width="107.33333333333331" align="center">Scope</th><th>Description</th></tr></thead><tbody><tr><td><code>setApp</code></td><td align="center"><code>public</code></td><td><code>Set the NestJS application instance.</code></td></tr><tr><td><code>getHttpServer</code></td><td align="center"><code>public</code></td><td><code>Returns the underlying native HTTP server.</code></td></tr><tr><td><code>getHttpAdapter</code></td><td align="center"><code>public</code></td><td><code>Returns the underlying HTTP adapter.</code></td></tr><tr><td><code>getMicroservices</code></td><td align="center"><code>public</code></td><td><code>Returns array of the microservices connected to the NestApplication.</code></td></tr><tr><td><code>getUrl</code></td><td align="center"><code>public</code></td><td><code>Returns the url the application is listening at, based on OS and IP version. Returns as an IP value either in IPv6 or IPv4</code></td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guilhermesantos.gitbook.io/niro-health/modules/app-host.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
