JSON5 adapter
Load configuration from a JSON5 file.
Loads the configuration from a json5 file.
Install
This adapter needs the json5 peer dependency, if you don't have it already:
npm install json5The JSON5 adapter is synchronous, so it also works with loadConfigSync.
Usage
{
// Server settings
host: 'localhost', // Single quotes + unquoted key
port: 3000, // Trailing comma
allowedIPs: [
'192.168.0.1',
'10.0.0.1', // Local access
],
}import { } from 'zod';
import { } from 'zod-config';
import { } from 'zod-config/json5-adapter';
import path from 'path';
const = path.(, 'config.json5');
const = .({
: .(),
: .(),
: .(.()),
});
const = await ({
: ,
: ({ : }),
});Options
| Option | Type | Description |
|---|---|---|
path | string | Path to the JSON5 file. Required. |
Also accepts the shared adapter options: regex, silent, keyMatching and transform.