This parser allows you to load configuration from .toml files.
Install the dependency.
pnpm add @layerfig/parser-toml
npm install @layerfig/parser-toml
yarn add @layerfig/parser-toml
bun add @layerfig/parser-toml
Create your configuration files.
Add the parser to your ConfigBuilder.
import { ConfigBuilder, FileSource } from "@layerfig/config";
import tomlParser from "@layerfig/parser-toml";
export const config = new ConfigBuilder({
validate: (finalConfig, z) => {
const schema = z.object({
appURL: z.url(),
port: z.number()
})
return schema.parse(finalConfig)
},
parser: tomlParser
})
.addSource(new FileSource("base.toml"))
.build();
Your application is now configured to parse these file formats.