[**Documentation**](../../../README)

***

[Documentation](../../../README) / [zerotal](../../README) / [config-reexport](../README) / configLoader

# Function: configLoader()

> **configLoader**(`dir?`): [`ConfigLoader`](../classes/ConfigLoader)

Defined in: [packages/core/src/config/ConfigLoader.ts:89](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/core/src/config/ConfigLoader.ts#L89)

Synchronously load every `*.ts` / `*.js` file in `dir` (default `./config`) into a namespace map
keyed by filename. Safe to call at the top level of an entry script (`zerotal.ts`) — no `await`.

Each file's **default export** is the config object; an optional named **`validate(config)`**
export is collected and run by `ConfigLoader.validate()`.

## Parameters

### dir?

`string` = `"./config"`

Directory to scan, relative to `process.cwd()`. Defaults to `./config`.

## Returns

[`ConfigLoader`](../classes/ConfigLoader)

A [ConfigLoader](../classes/ConfigLoader) over the discovered namespaces. A missing
directory yields an empty loader rather than throwing.

## Example

```ts
const config = configLoader("./config");
config.validate();
const app = Application.create({ config });   // or app.useConfig(config)
```
