@forgeframework/config
v0.3.0
Published
Provides typed, validated configuration management for the Forge Framework.
Maintainers
Readme
@forgeframework/config
Provides typed, validated configuration management for the Forge Framework.
Part of the Forge Framework — a TypeScript framework for backend microservices and web applications.
Installation
npm install @forgeframework/configUsage
import { ConfigLoader } from '@forgeframework/config';
const loader = new ConfigLoader({
envPrefix: 'FORGE',
sources: [
{ type: 'file', path: './config/default.json' },
{ type: 'file', path: `./config/${process.env.NODE_ENV}.json`, optional: true },
{ type: 'env', prefix: 'FORGE', separator: '__' },
],
schema: {
properties: {
server: {
type: 'object',
properties: {
port: { type: 'number', default: 3000 },
host: { type: 'string', default: '0.0.0.0' },
},
},
database: {
type: 'object',
properties: {
host: { type: 'string' },
port: { type: 'number', default: 5432 },
password: { type: 'string', secret: true },
},
required: ['host'],
},
},
},
});
const config = await loader.load();
const port = config.get<number>('server.port'); // 3000
const dbHost = config.getOrThrow<string>('database.host');Documentation
Full API reference and guides: https://carbonforge.io/framework/docs/core/config
(Documentation site launching soon.)
License
MIT © Carbon Forge
