# ApplicationConfig

**Kind:** Class

**Source:** [`packages/core/application-config.ts`](https://github.com/nestjs/nest/blob/master/packages/core/application-config.ts#L13)

**Part of:** [Core](subsystem-packages-core)

`ApplicationConfig` stores application-wide runtime configuration used by the NestJS application bootstrap process. It manages global HTTP prefix settings, WebSocket adapters, pipes, and exception filters so these concerns can be applied consistently across the application.

## Methods

| Method | Signature | Returns |
|---|---|---|
| `setGlobalPrefix` | `setGlobalPrefix(prefix: string)` | `void` |
| `getGlobalPrefix` | `getGlobalPrefix()` | `void` |
| `setGlobalPrefixOptions` | `setGlobalPrefixOptions(options: GlobalPrefixOptions<ExcludeRouteMetadata>)` | `void` |
| `getGlobalPrefixOptions` | `getGlobalPrefixOptions()` | `GlobalPrefixOptions<ExcludeRouteMetadata>` |
| `setIoAdapter` | `setIoAdapter(ioAdapter: WebSocketAdapter)` | `void` |
| `getIoAdapter` | `getIoAdapter()` | `WebSocketAdapter` |
| `addGlobalPipe` | `addGlobalPipe(pipe: PipeTransform<any>)` | `void` |
| `useGlobalPipes` | `useGlobalPipes(pipes: PipeTransform<any>[])` | `void` |
| `getGlobalFilters` | `getGlobalFilters()` | `ExceptionFilter[]` |
| `addGlobalFilter` | `addGlobalFilter(filter: ExceptionFilter)` | `void` |
| `useGlobalFilters` | `useGlobalFilters(filters: ExceptionFilter[])` | `void` |
| `getGlobalPipes` | `getGlobalPipes()` | `PipeTransform<any>[]` |
| `getGlobalInterceptors` | `getGlobalInterceptors()` | `NestInterceptor[]` |
| `addGlobalInterceptor` | `addGlobalInterceptor(interceptor: NestInterceptor)` | `void` |
| `useGlobalInterceptors` | `useGlobalInterceptors(interceptors: NestInterceptor[])` | `void` |
| `getGlobalGuards` | `getGlobalGuards()` | `CanActivate[]` |
| `addGlobalGuard` | `addGlobalGuard(guard: CanActivate)` | `void` |
| `useGlobalGuards` | `useGlobalGuards(guards: CanActivate[])` | `void` |
| `addGlobalRequestInterceptor` | `addGlobalRequestInterceptor(wrapper: InstanceWrapper<NestInterceptor>)` | `void` |
| `getGlobalRequestInterceptors` | `getGlobalRequestInterceptors()` | `InstanceWrapper<NestInterceptor>[]` |
| `addGlobalRequestPipe` | `addGlobalRequestPipe(wrapper: InstanceWrapper<PipeTransform>)` | `void` |
| `getGlobalRequestPipes` | `getGlobalRequestPipes()` | `InstanceWrapper<PipeTransform>[]` |
| `addGlobalRequestFilter` | `addGlobalRequestFilter(wrapper: InstanceWrapper<ExceptionFilter>)` | `void` |
| `getGlobalRequestFilters` | `getGlobalRequestFilters()` | `InstanceWrapper<ExceptionFilter>[]` |
| `addGlobalRequestGuard` | `addGlobalRequestGuard(wrapper: InstanceWrapper<CanActivate>)` | `void` |
| `getGlobalRequestGuards` | `getGlobalRequestGuards()` | `InstanceWrapper<CanActivate>[]` |
| `enableVersioning` | `enableVersioning(options: VersioningOptions)` | `void` |
| `getVersioning` | `getVersioning()` | `VersioningOptions | undefined` |

## Diagram

```mermaid
graph LR
  App[Nest Application] --> Config[ApplicationConfig]

  Config --> Prefix[Global Prefix]
  Config --> PrefixOptions[Prefix Exclusion Options]
  Config --> IoAdapter[WebSocket Adapter]
  Config --> Pipes[Global Pipes]
  Config --> Filters[Global Exception Filters]

  Prefix --> Routes[HTTP Routes]
  IoAdapter --> Gateways[WebSocket Gateways]
  Pipes --> Requests[Incoming Requests]
  Filters --> Errors[Unhandled Exceptions]
```

## Usage

```ts
import { RequestMethod, ValidationPipe } from '@nestjs/common';
import { ApplicationConfig } from '@nestjs/core/application-config';
import { WsAdapter } from '@nestjs/platform-ws';

const config = new ApplicationConfig();

// Configure HTTP route prefixing.
config.setGlobalPrefix('api');
config.setGlobalPrefixOptions({
  exclude: [{ path: 'health', method: RequestMethod.GET }],
});

// Apply request validation globally.
config.addGlobalPipe(
  new ValidationPipe({
    transform: true,
    whitelist: true,
  }),
);

// Configure the WebSocket transport adapter.
config.setIoAdapter(new WsAdapter());

// Inspect configured values when integrating with application bootstrap.
console.log(config.getGlobalPrefix()); // "api"
console.log(config.getIoAdapter());
console.log(config.getGlobalFilters());
```

## AI Coding Instructions

- Use `setGlobalPrefix()` and `setGlobalPrefixOptions()` together when routes need a shared prefix with explicit exclusions.
- Prefer `useGlobalPipes(...pipes)` when registering multiple pipes at once; use `addGlobalPipe()` for incremental registration.
- Ensure global pipes and filters are registered during application setup, before handling requests or initializing gateways.
- Provide a valid `WebSocketAdapter` implementation through `setIoAdapter()` before starting WebSocket gateway infrastructure.
- Treat values returned by getters as application-wide configuration state; avoid mutating returned collections directly.

## Relationships

- IMPORTS → `CanActivate`
- IMPORTS → `ExceptionFilter`
- IMPORTS → `NestInterceptor`
- IMPORTS → `PipeTransform`
- IMPORTS → `VersioningOptions`
- IMPORTS → `WebSocketAdapter`
- IMPORTS → `GlobalPrefixOptions`

## Used by

8 references from 8 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (8)

- `ExceptionFiltersContext` — `packages/microservices/context/exception-filters-context.ts`:16
- `MicroservicesModule` — `packages/microservices/microservices-module.ts`:23
- `NestMicroservice` — `packages/microservices/nest-microservice.ts`:35
- `TestingModuleOptions` — `packages/testing/testing-module.builder.ts`:29
- `TestingModule` — `packages/testing/testing-module.ts`:26
- `SocketModule` — `packages/websockets/socket-module.ts`:27
- `SocketServerProvider` — `packages/websockets/socket-server-provider.ts`:8
- `WebSocketsController` — `packages/websockets/web-sockets-controller.ts`:29
