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