API

Formatting#

Discover the ways to make your configuration exactly how you want to!

.setNamingConvention(convention)#

With this formatting option, you can setup a naming convention for all of your configuration items. By default camelCase is used.

The convention parameter can be either one of our presets (see code snippet below), or a function ((segment: string) => string) that defines your own naming convention. Keys are passed in as SCREAMING_SNAKE_CASE with double underscores to indicate a nested level (FOO__BAR__BAZ).

Configured naming conventions get overwritten if you use a schema.

import { createConfigLoader, pascalCaseNaming, camelCaseNaming, screamingSnakeCaseNaming, snakeCaseNaming } from 'neat-config';
import { z } from 'zod';
 
process.env = {
  FOO_BAR___BAR__BAZ: "hello world"
}
 
// presets:
//  - camelCaseNaming (default)
//  - pascalCaseNaming
//  - screamingSnakeCaseNaming
//  - snakeCaseNaming
 
export const config = createConfigLoader()
  .addFromEnvironment()
  .setNamingConvention(pascalCaseNaming)
  .load();

.unfreeze()#

by default, Your configuration is deep frozen using recursive Object.freeze(). This means that you will get runtime errors when you try to assign anything, in typescript you will get a readonly type so you get compiler errors when trying to assign.

If you use the unfreeze() option, your output configuration will not be frozen as described above.