# Envapter

Reads typed environment variables on Node, Bun, and Deno. It adds the filesystem-only configuration
APIs: `.env` path selection, base directory, dotenv options, and per-environment profiles. On the
portable build (Workers, the browser, edge) these same APIs warn once and do nothing, unless
`Envapter.fileApiMode` is `'throw'`.

## Accessors

### baseDir

#### Get Signature

```ts
get static baseDir(): string | undefined;
```

The configured base directory, or `undefined` when relative paths resolve against the working directory.

##### See

[https://envapt.materwelon.dev/docs/env-files#reading-from-a-fixed-directory](https://envapt.materwelon.dev/docs/env-files#reading-from-a-fixed-directory)

##### Returns

`string` \| `undefined`

#### Set Signature

```ts
set static baseDir(value): void;
```

Set the base directory that relative `.env` paths resolve against. Without one they resolve against
`process.cwd()`. It covers the auto-cascade, `Envapter.configureProfiles` paths, and relative `envPaths`.
Absolute paths always bypass it. Pass a directory path (`import.meta.dirname`) or a module URL
(`import.meta.url`) to resolve paths next to the calling file regardless of launch directory.

Set this before `envPaths` so relative `envPaths` validate against the right directory.
Setting `undefined` restores `process.cwd()` resolution.

##### See

[https://envapt.materwelon.dev/docs/env-files#reading-from-a-fixed-directory](https://envapt.materwelon.dev/docs/env-files#reading-from-a-fixed-directory)

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `value` | `string` \| `URL` \| `undefined` |

##### Returns

`void`

***

### debug

#### Get Signature

```ts
get static debug(): DebugLevel;
```

##### Returns

[`DebugLevel`](../type-aliases/DebugLevel.mdx)

#### Set Signature

```ts
set static debug(level): void;
```

Set the debug log level. Defaults to `silent`. When unset, reads `ENVAPT_DEBUG` from the
bound source on first access. The setter overrides any env-var value. Output goes to stderr
on Node (the console elsewhere), prefixed with `[envapt]`.

##### See

[https://envapt.materwelon.dev/docs/errors#debug-logging](https://envapt.materwelon.dev/docs/errors#debug-logging)

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `level` | [`DebugLevel`](../type-aliases/DebugLevel.mdx) |

##### Returns

`void`

#### Inherited from

```ts
Envapter.debug
```

***

### envFileOptions

#### Get Signature

```ts
get static envFileOptions(): EnvFileOptions;
```

The env file loader options.

##### See

[https://envapt.materwelon.dev/docs/env-files#file-options](https://envapt.materwelon.dev/docs/env-files#file-options)

##### Returns

[`EnvFileOptions`](../interfaces/EnvFileOptions.mdx)

#### Set Signature

```ts
set static envFileOptions(config): void;
```

Set the env file loader options (`encoding`, `override`). Refreshes the cache. Any other key
throws `InvalidUserDefinedConfig`.

##### See

[https://envapt.materwelon.dev/docs/env-files#file-options](https://envapt.materwelon.dev/docs/env-files#file-options)

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `config` | [`EnvFileOptions`](../interfaces/EnvFileOptions.mdx) |

##### Returns

`void`

***

### environment

#### Get Signature

```ts
get static environment(): Environment;
```

The current application environment, detected on first read unless you set it.

##### See

[https://envapt.materwelon.dev/docs/environment#detecting-the-environment](https://envapt.materwelon.dev/docs/environment#detecting-the-environment)

##### Returns

[`Environment`](../type-aliases/Environment.mdx)

#### Set Signature

```ts
set static environment(env): void;
```

Set the application environment to an [Environment](../variables/Environment.mdx) value such as `'production'`, matched
case-insensitively. An unknown name selects `'development'`. Setting it reloads the `.env` files
for that environment.

##### See

[https://envapt.materwelon.dev/docs/environment#detecting-the-environment](https://envapt.materwelon.dev/docs/environment#detecting-the-environment)

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `env` | [`Environment`](../type-aliases/Environment.mdx) \| `string` & `object` |

##### Returns

`void`

#### Inherited from

```ts
Envapter.environment
```

***

### envPaths

#### Get Signature

```ts
get static envPaths(): string[];
```

The configured .env file paths.

##### See

[https://envapt.materwelon.dev/docs/env-files#choosing-the-files-yourself](https://envapt.materwelon.dev/docs/env-files#choosing-the-files-yourself)

##### Returns

`string`[]

#### Set Signature

```ts
set static envPaths(paths): void;
```

Set custom .env file paths. Setting new paths clears the cache and reloads environment
variables. Throws `EnvFilesNotFound` when a path does not exist.

Once set, these paths replace the dotenv-flow auto-cascade and any `Envapter.configureProfiles`
paths.

##### See

[https://envapt.materwelon.dev/docs/env-files#choosing-the-files-yourself](https://envapt.materwelon.dev/docs/env-files#choosing-the-files-yourself)

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `paths` | `string` \| `string`[] |

##### Returns

`void`

***

### fileApiMode

#### Get Signature

```ts
get static fileApiMode(): FileApiMode;
```

##### Returns

[`FileApiMode`](../type-aliases/FileApiMode.mdx)

#### Set Signature

```ts
set static fileApiMode(mode): void;
```

On the portable build, this controls the filesystem-only config APIs (`envPaths`, `baseDir`,
`envFileOptions`, `configureProfiles`, `resetPaths`). `'warn'` (the default) warns once and
does nothing. `'throw'` throws [EnvaptError](./EnvaptError.mdx) `FileApiUnsupported`. The node build runs these
APIs normally and this value has no effect there.

##### See

[https://envapt.materwelon.dev/docs/compatibility#file-apis-and-fileapimode](https://envapt.materwelon.dev/docs/compatibility#file-apis-and-fileapimode)

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `mode` | [`FileApiMode`](../type-aliases/FileApiMode.mdx) |

##### Returns

`void`

#### Inherited from

```ts
Envapter.fileApiMode
```

***

### isDevelopment

#### Get Signature

```ts
get static isDevelopment(): boolean;
```

Whether the current environment is development.

##### See

[https://envapt.materwelon.dev/docs/environment#branching-on-the-environment](https://envapt.materwelon.dev/docs/environment#branching-on-the-environment)

##### Returns

`boolean`

#### Inherited from

```ts
Envapter.isDevelopment
```

***

### isProduction

#### Get Signature

```ts
get static isProduction(): boolean;
```

Whether the current environment is production.

##### See

[https://envapt.materwelon.dev/docs/environment#branching-on-the-environment](https://envapt.materwelon.dev/docs/environment#branching-on-the-environment)

##### Returns

`boolean`

#### Inherited from

```ts
Envapter.isProduction
```

***

### isStaging

#### Get Signature

```ts
get static isStaging(): boolean;
```

Whether the current environment is staging.

##### See

[https://envapt.materwelon.dev/docs/environment#branching-on-the-environment](https://envapt.materwelon.dev/docs/environment#branching-on-the-environment)

##### Returns

`boolean`

#### Inherited from

```ts
Envapter.isStaging
```

***

### isTest

#### Get Signature

```ts
get static isTest(): boolean;
```

Whether the current environment is test.

##### See

[https://envapt.materwelon.dev/docs/environment#branching-on-the-environment](https://envapt.materwelon.dev/docs/environment#branching-on-the-environment)

##### Returns

`boolean`

#### Inherited from

```ts
Envapter.isTest
```

***

### strict

#### Get Signature

```ts
get static strict(): boolean;
```

##### Returns

`boolean`

#### Set Signature

```ts
set static strict(value): void;
```

When `true`, a whitespace-only value counts as missing, a `${VAR}` that can't resolve throws
`MissingEnvValue`, and an empty array element throws `EmptyArrayElement`. Default `false`.
Setting it clears and rebuilds the cache.

##### See

[https://envapt.materwelon.dev/docs/required-values#strict-mode](https://envapt.materwelon.dev/docs/required-values#strict-mode)

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `value` | `boolean` |

##### Returns

`void`

#### Inherited from

```ts
Envapter.strict
```

***

### syncProcessEnv

#### Get Signature

```ts
get static syncProcessEnv(): boolean;
```

##### Returns

`boolean`

#### Set Signature

```ts
set static syncProcessEnv(value): void;
```

When `true`, copies dotenv-loaded keys into `process.env`. Default `false`.

`envFileOptions.override` controls collisions because only keys the loader wrote are copied.
With the default `false`, existing `process.env` values stay. With `true`, the file value
replaces them in both the cache and `process.env`.

Flipping `false → true` copies the loaded keys immediately without a cache refresh.
Flipping `true → false` leaves copied keys in `process.env` until the process exits.

##### See

[https://envapt.materwelon.dev/docs/env-files#file-options](https://envapt.materwelon.dev/docs/env-files#file-options)

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `value` | `boolean` |

##### Returns

`void`

#### Inherited from

```ts
Envapter.syncProcessEnv
```

## Methods

### configureProfiles()

```ts
static configureProfiles(config): void;
```

Configure per-environment `.env` path overrides on top of the dotenv-flow auto-cascade.

When set, each `Environment` key's `paths` load ahead of the cascade for that environment and
win over it, unless `envFileOptions.override` is `true`. Unspecified environments still use the
cascade as-is.
Set `useDefaults: false` to disable the cascade entirely (load only the configured paths).

Setting an explicit `Envapter.envPaths` value at any point overrides this configuration.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `config` | [`ProfilesConfig`](../type-aliases/ProfilesConfig.mdx) |

#### Returns

`void`

#### Example

```ts
Envapter.configureProfiles({
  staging: { paths: 'config/staging.env' },
  production: { paths: ['config/prod.env', 'secrets/prod.env'] }
});
```

#### See

[https://envapt.materwelon.dev/docs/env-files#profiles](https://envapt.materwelon.dev/docs/env-files#profiles)

***

### get()

```ts
static get<Default>(key, fallback?): ConditionalReturn<string, Default>;
```

Get a string environment variable, or `fallback` when it is missing or empty. Expands
`${VAR}` templates in the value. Accepts a single key or an ordered array of keys, read until
one has a value. Read any other type with `getAs` and a converter.

#### Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
|  `Default` *extends* `string` \| `undefined` | `undefined` |

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `EnvKeyInput` |
| `fallback?` | `Default` |

#### Returns

`ConditionalReturn`\<`string`, `Default`\>

#### See

[https://envapt.materwelon.dev/docs/envapter#strings-and-typed-values](https://envapt.materwelon.dev/docs/envapter#strings-and-typed-values)

#### Inherited from

```ts
Envapter.get
```

***

### getAs()

#### Call Signature

```ts
static getAs<TConverter, TFallback>(
   key, 
   converter, 
   fallback?
): AdvancedConverterReturn<TConverter, TFallback>;
```

Get an environment variable through a converter: a built-in token such as `Converters.Number`,
an `ArrayOf` token from `Converters.array(...)`, a custom `(raw: string) => T` function, or a
synchronous Standard Schema (zod, valibot, arktype). A missing value returns the fallback, or
`undefined` without one. A scalar token or a function that can't convert the value returns the
fallback too. A bad array element throws `ArrayElementConversionFailed`. A schema that rejects
the value throws `SchemaValidationFailed`. envapt never runs the schema on the fallback. The key
can be a single name or an ordered list, read until one key has a value.
A bad converter or fallback throws even when the value is missing.

##### Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
|  `TConverter` *extends* `ConverterToken` \| `ArrayOf`\<`ArrayElement`\> | - |
|  `TFallback` *extends* \| `string` \| `number` \| `bigint` \| `boolean` \| `RegExp` \| `string`[] \| `JsonArray` \| `JsonObject` \| `URL` \| `Date` \| `unknown`[] \| `number`[] \| `bigint`[] \| `boolean`[] \| `URL`[] \| `Date`[] \| [`TimeFallback`](../type-aliases/TimeFallback.mdx)[] \| `object`[] \| `null` \| `undefined` | `undefined` |

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `EnvKeyInput` |
| `converter` | `TConverter` |
| `fallback?` | `TFallback` |

##### Returns

`AdvancedConverterReturn`\<`TConverter`, `TFallback`\>

##### See

 - [https://envapt.materwelon.dev/docs/envapter#other-types-with-getas](https://envapt.materwelon.dev/docs/envapter#other-types-with-getas)
 - [https://envapt.materwelon.dev/docs/converters#custom-converters](https://envapt.materwelon.dev/docs/converters#custom-converters)

##### Inherited from

```ts
Envapter.getAs
```

#### Call Signature

```ts
static getAs<TReturn>(
   key, 
   converter, 
   fallback
): TReturn;
```

Get an environment variable through a converter: a built-in token such as `Converters.Number`,
an `ArrayOf` token from `Converters.array(...)`, a custom `(raw: string) => T` function, or a
synchronous Standard Schema (zod, valibot, arktype). A missing value returns the fallback, or
`undefined` without one. A scalar token or a function that can't convert the value returns the
fallback too. A bad array element throws `ArrayElementConversionFailed`. A schema that rejects
the value throws `SchemaValidationFailed`. envapt never runs the schema on the fallback. The key
can be a single name or an ordered list, read until one key has a value.
A bad converter or fallback throws even when the value is missing.

##### Type Parameters

| Type Parameter |
| ------ |
|  `TReturn` |

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `EnvKeyInput` |
| `converter` | `"json"` |
| `fallback` | `TReturn` |

##### Returns

`TReturn`

##### See

 - [https://envapt.materwelon.dev/docs/envapter#other-types-with-getas](https://envapt.materwelon.dev/docs/envapter#other-types-with-getas)
 - [https://envapt.materwelon.dev/docs/converters#custom-converters](https://envapt.materwelon.dev/docs/converters#custom-converters)

##### Inherited from

```ts
Envapter.getAs
```

#### Call Signature

```ts
static getAs<TReturn>(
   key, 
   converter, 
   fallback?
): TReturn | undefined;
```

Get an environment variable through a converter: a built-in token such as `Converters.Number`,
an `ArrayOf` token from `Converters.array(...)`, a custom `(raw: string) => T` function, or a
synchronous Standard Schema (zod, valibot, arktype). A missing value returns the fallback, or
`undefined` without one. A scalar token or a function that can't convert the value returns the
fallback too. A bad array element throws `ArrayElementConversionFailed`. A schema that rejects
the value throws `SchemaValidationFailed`. envapt never runs the schema on the fallback. The key
can be a single name or an ordered list, read until one key has a value.
A bad converter or fallback throws even when the value is missing.

##### Type Parameters

| Type Parameter |
| ------ |
|  `TReturn` |

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `EnvKeyInput` |
| `converter` | `"json"` |
| `fallback?` | `TReturn` |

##### Returns

`TReturn` \| `undefined`

##### See

 - [https://envapt.materwelon.dev/docs/envapter#other-types-with-getas](https://envapt.materwelon.dev/docs/envapter#other-types-with-getas)
 - [https://envapt.materwelon.dev/docs/converters#custom-converters](https://envapt.materwelon.dev/docs/converters#custom-converters)

##### Inherited from

```ts
Envapter.getAs
```

#### Call Signature

```ts
static getAs<Schema, TFallback>(
   key, 
   schema, 
   fallback?
): ConditionalReturn<InferSchemaOutput<Schema>, TFallback>;
```

Get an environment variable through a converter: a built-in token such as `Converters.Number`,
an `ArrayOf` token from `Converters.array(...)`, a custom `(raw: string) => T` function, or a
synchronous Standard Schema (zod, valibot, arktype). A missing value returns the fallback, or
`undefined` without one. A scalar token or a function that can't convert the value returns the
fallback too. A bad array element throws `ArrayElementConversionFailed`. A schema that rejects
the value throws `SchemaValidationFailed`. envapt never runs the schema on the fallback. The key
can be a single name or an ordered list, read until one key has a value.
A bad converter or fallback throws even when the value is missing.

##### Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
|  `Schema` *extends* [`StandardSchemaV1`](../interfaces/StandardSchemaV1.mdx)\<`unknown`, `unknown`\> | - |
|  `TFallback` *extends* `unknown` | `undefined` |

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `EnvKeyInput` |
| `schema` | `SchemaConstraint`\<`Schema`\> |
| `fallback?` | `TFallback` |

##### Returns

`ConditionalReturn`\<`InferSchemaOutput`\<`Schema`\>, `TFallback`\>

##### See

 - [https://envapt.materwelon.dev/docs/envapter#other-types-with-getas](https://envapt.materwelon.dev/docs/envapter#other-types-with-getas)
 - [https://envapt.materwelon.dev/docs/converters#custom-converters](https://envapt.materwelon.dev/docs/converters#custom-converters)

##### Inherited from

```ts
Envapter.getAs
```

#### Call Signature

```ts
static getAs<TReturn, TFallback>(
   key, 
   converter, 
   fallback?
): ConditionalReturn<NonNullable<TReturn>, TFallback>;
```

Get an environment variable through a converter: a built-in token such as `Converters.Number`,
an `ArrayOf` token from `Converters.array(...)`, a custom `(raw: string) => T` function, or a
synchronous Standard Schema (zod, valibot, arktype). A missing value returns the fallback, or
`undefined` without one. A scalar token or a function that can't convert the value returns the
fallback too. A bad array element throws `ArrayElementConversionFailed`. A schema that rejects
the value throws `SchemaValidationFailed`. envapt never runs the schema on the fallback. The key
can be a single name or an ordered list, read until one key has a value.
A bad converter or fallback throws even when the value is missing.

##### Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
|  `TReturn` | - |
|  `TFallback` *extends* \| \{ \} \| `undefined` | `undefined` |

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `EnvKeyInput` |
| `converter` | [`ConverterFunction`](../type-aliases/ConverterFunction.mdx)\<`TReturn`\> |
| `fallback?` | `TFallback` |

##### Returns

`ConditionalReturn`\<`NonNullable`\<`TReturn`\>, `TFallback`\>

##### See

 - [https://envapt.materwelon.dev/docs/envapter#other-types-with-getas](https://envapt.materwelon.dev/docs/envapter#other-types-with-getas)
 - [https://envapt.materwelon.dev/docs/converters#custom-converters](https://envapt.materwelon.dev/docs/converters#custom-converters)

##### Inherited from

```ts
Envapter.getAs
```

***

### getRaw()

```ts
static getRaw(key): string | undefined;
```

Read an environment variable as its raw string, skipping parsing and conversion. A `${NAME}`
reference in the value comes back unexpanded.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `EnvKeyInput` |

#### Returns

`string` \| `undefined`

#### See

[https://envapt.materwelon.dev/docs/envapter#the-raw-string](https://envapt.materwelon.dev/docs/envapter#the-raw-string)

#### Inherited from

```ts
Envapter.getRaw
```

***

### getRequired()

#### Call Signature

```ts
static getRequired<TConverter>(key, converter): InferConverterReturnType<TConverter>;
```

Read a required environment variable and convert it, throwing `MissingEnvValue` when the value
is missing or empty. A value it cannot convert throws `InvalidEnvValue` with issues keyed by
the env name. A bad array element, an error a custom parser or schema throws, and a schema's
own issues all become issues on that error. Accepts a built-in or `ArrayOf` token, a custom
parser function, or a synchronous Standard Schema. The key can be a single name or an ordered list.
A bad converter throws before `MissingEnvValue`.

##### Type Parameters

| Type Parameter |
| ------ |
|  `TConverter` *extends* `ConverterToken` \| `ArrayOf`\<`ArrayElement`\> |

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `EnvKeyInput` |
| `converter` | `TConverter` |

##### Returns

`InferConverterReturnType`\<`TConverter`\>

##### See

[https://envapt.materwelon.dev/docs/required-values#getrequired-require-and-has](https://envapt.materwelon.dev/docs/required-values#getrequired-require-and-has)

##### Inherited from

```ts
Envapter.getRequired
```

#### Call Signature

```ts
static getRequired<Schema>(key, schema): InferSchemaOutput<Schema>;
```

Read a required environment variable and convert it, throwing `MissingEnvValue` when the value
is missing or empty. A value it cannot convert throws `InvalidEnvValue` with issues keyed by
the env name. A bad array element, an error a custom parser or schema throws, and a schema's
own issues all become issues on that error. Accepts a built-in or `ArrayOf` token, a custom
parser function, or a synchronous Standard Schema. The key can be a single name or an ordered list.
A bad converter throws before `MissingEnvValue`.

##### Type Parameters

| Type Parameter |
| ------ |
|  `Schema` *extends* [`StandardSchemaV1`](../interfaces/StandardSchemaV1.mdx)\<`unknown`, `unknown`\> |

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `EnvKeyInput` |
| `schema` | `SchemaConstraint`\<`Schema`\> |

##### Returns

`InferSchemaOutput`\<`Schema`\>

##### See

[https://envapt.materwelon.dev/docs/required-values#getrequired-require-and-has](https://envapt.materwelon.dev/docs/required-values#getrequired-require-and-has)

##### Inherited from

```ts
Envapter.getRequired
```

#### Call Signature

```ts
static getRequired<TReturnType>(key, converter): NonNullable<TReturnType>;
```

Read a required environment variable and convert it, throwing `MissingEnvValue` when the value
is missing or empty. A value it cannot convert throws `InvalidEnvValue` with issues keyed by
the env name. A bad array element, an error a custom parser or schema throws, and a schema's
own issues all become issues on that error. Accepts a built-in or `ArrayOf` token, a custom
parser function, or a synchronous Standard Schema. The key can be a single name or an ordered list.
A bad converter throws before `MissingEnvValue`.

##### Type Parameters

| Type Parameter |
| ------ |
|  `TReturnType` |

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `EnvKeyInput` |
| `converter` | [`ConverterFunction`](../type-aliases/ConverterFunction.mdx)\<`TReturnType`\> |

##### Returns

`NonNullable`\<`TReturnType`\>

##### See

[https://envapt.materwelon.dev/docs/required-values#getrequired-require-and-has](https://envapt.materwelon.dev/docs/required-values#getrequired-require-and-has)

##### Inherited from

```ts
Envapter.getRequired
```

***

### getRequiredAll()

```ts
static getRequiredAll<Spec, Casing>(spec, casing?): { [K in string | number | symbol as RecaseKey<K & string, Casing>]: InferSpecField<Spec[K]> };
```

Read a group of required environment variables in one call. Each key in `spec` maps to a
converter (a token, an `array()` token, or a custom parser) or a synchronous Standard Schema
(zod, valibot, arktype, etc). The returned record holds every value. A converter field is
never undefined. A schema field holds whatever its schema returns.

A bad converter in `spec` throws first. envapt then collects every missing or empty key and
throws one `MissingEnvValue` listing them all. envapt never runs the schema for a missing key,
so a schema default such as zod's `.default()` does not apply here.
If no key is missing, envapt reads every field and throws one `InvalidEnvValue` for all
the bad values, schema fields included. Its `issues` hold every failed field's issues, each
with its env key first in `path`. A converter that cannot convert adds the issue
`could not be converted`. A bad array element and an error a custom parser or schema throws
each become an issue carrying their message.
The error message lists only the keys, since an issue message can quote the value.

Pass a `casing` (`'camelCase'`, `'PascalCase'`, or `'kebab-case'`) to rename the record keys.
The rename splits each key on underscores, as in SCREAMING_SNAKE env-var names. With no casing
the keys stay as-is.

#### Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
|  `Spec` *extends* `RequiredSpec` | - |
|  `Casing` *extends* `KeyCasing` \| `undefined` | `undefined` |

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spec` | `Spec` & `SpecSchemaConstraint`\<`Spec`\> |
| `casing?` | `Casing` |

#### Returns

\{ \[K in string \| number \| symbol as RecaseKey\<K & string, Casing\>\]: InferSpecField\<Spec\[K\]\> \}

#### See

[https://envapt.materwelon.dev/docs/required-values](https://envapt.materwelon.dev/docs/required-values)

#### Inherited from

```ts
Envapter.getRequiredAll
```

***

### has()

```ts
static has(key): boolean;
```

Check whether `key` has a value. An unset or empty value counts as missing, the same as in
`getRequired`. Under strict mode, a value whose `${VAR}` can't resolve counts as missing too,
and an ordered key list returns `false` at that key without checking the later ones.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `key` | `EnvKeyInput` |

#### Returns

`boolean`

#### Example

```ts
const cache = Envapter.has('REDIS_URL') ? createRedisCache() : createMemoryCache();
```

#### See

[https://envapt.materwelon.dev/docs/required-values#getrequired-require-and-has](https://envapt.materwelon.dev/docs/required-values#getrequired-require-and-has)

#### Inherited from

```ts
Envapter.has
```

***

### require()

```ts
static require(...keys): void;
```

Assert that one or more environment variables are present and non-empty after template
resolution. Throws `MissingEnvValue` listing every missing key. A whitespace-only value
counts as missing only under strict mode. Each argument can be an ordered key list, which
passes when any of its keys has a value.

For a typed required read in functional code, use `Envapter.getRequired(key, converter)`.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| ...`keys` | \[`EnvKeyInput`, `...EnvKeyInput[]`\] |

#### Returns

`void`

#### Example

```ts
Envapter.require('DATABASE_URL');
Envapter.require('DATABASE_URL', 'API_KEY', 'SENTRY_DSN');
Envapter.require(['READONLY_URL', 'DATABASE_URL'], 'API_KEY');
```

#### Inherited from

```ts
Envapter.require
```

***

### resetPaths()

```ts
static resetPaths(): void;
```

Clears any `Envapter.configureProfiles` call, any explicit `Envapter.envPaths` assignment, and any
environment set through `Envapter.environment`. `Envapter.baseDir` keeps its value. The call
reloads the dotenv-flow cascade right away, choosing the files from the environment set in your
env vars.

#### Returns

`void`

#### See

[https://envapt.materwelon.dev/docs/env-files#profiles](https://envapt.materwelon.dev/docs/env-files#profiles)

***

### resolve()

```ts
static resolve(strings, ...keys): string;
```

Tagged template literal for resolving environment variables in template strings. A missing
value resolves to an empty string. In strict mode an empty or whitespace-only value throws
`MissingEnvValue`.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `strings` | `TemplateStringsArray` |
| ...`keys` | `EnvKeyInput`[] |

#### Returns

`string`

#### Example

```ts
// Given API_HOST=api.example.com and API_PORT=8080 in environment
const endpoint = Envapter.resolve`Connecting to ${'API_HOST'}:${'API_PORT'}`;
// Returns: "Connecting to api.example.com:8080"

// Works with template variables in .env too:
// API_URL=https://${API_HOST}:${API_PORT}
const message = Envapter.resolve`Service endpoint: ${'API_URL'}`;
// Returns: "Service endpoint: https://api.example.com:8080"

// reads READONLY_URL when present, otherwise DATABASE_URL
const db = Envapter.resolve`Connecting to ${['READONLY_URL', 'DATABASE_URL']}`;
```

#### See

[https://envapt.materwelon.dev/docs/templates#the-resolve-tagged-template](https://envapt.materwelon.dev/docs/templates#the-resolve-tagged-template)

#### Inherited from

```ts
Envapter.resolve
```

***

### useSource()

```ts
static useSource(source): void;
```

Bind the environment [Source](../type-aliases/Source.mdx). On Node the entry binds [FileSource](./FileSource.mdx) for you
(a `process.env` snapshot plus the `.env` cascade). On the browser or Workers, pass a
`PortableSource` (or any `Source`) before reading. Pass a `(key) => string | undefined` reader for
a source that reads one key at a time and cannot list its keys. Clears and rebuilds the cache.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `source` | \| [`Source`](../type-aliases/Source.mdx) \| ((`key`) => `string` \| `undefined`) |

#### Returns

`void`

#### See

[https://envapt.materwelon.dev/docs/sources#the-sources-envapt-ships](https://envapt.materwelon.dev/docs/sources#the-sources-envapt-ships)

#### Inherited from

```ts
Envapter.useSource
```