confconf-typebox
Integrates @confconf/confconf
with @sinclair/typebox
.
Install
npm i --save @confconf/confconf-typebox @sinclair/typebox
Usage
import { confconf, envConfig } from "@confconf/confconf-typebox";
import { Static, Type } from "@sinclair/typebox";
const configSchema = Type.Object({
port: Type.Number(),
db: Type.Object({
host: Type.String(),
name: Type.String(),
}),
});
type Config = Static<typeof configSchema>;
const config = await confconf({
schema: configSchema,
providers: [
envConfig({
structure: {
port: "PORT",
db: {
host: "DB_HOST",
name: "DB_NAME",
},
},
}),
],
}).loadAndValidate();