Optionaloptions: ConfigPluginOptions
Plugin configuration
The plugin instance
import { ConfigPlugin } from '@setu-ts/config-plugin';
import { z } from 'zod';
const AppConfigSchema = z.object({
PORT: z.coerce.number().default(3000),
DATABASE_URL: z.string().url(),
});
app.register(ConfigPlugin({
envFilePath: ['.env.local', '.env'],
validationSchema: AppConfigSchema,
expandVariables: true,
}));
Creates the ConfigPlugin.
The plugin depends on the runtime plugin (
CAPABILITIES.RUNTIME) and registers itsIConfigunderCAPABILITIES.CONFIGatPLUGIN_PRIORITY.HIGH(100) so configuration is available before most other plugins register.Registration may be async because env files are loaded asynchronously through
runtime.fs.