Config Structure
Yumeri uses Schema to define the configuration structure for plugins. The parsed configuration (with default values) is automatically injected during plugin loading.
Defining a Schema
Regardless of the API mode, you need to define a config export of type Schema:
ts
import { Schema } from 'yumeri'
export interface MyConfig {
port: number;
}
export const config: Schema<MyConfig> = Schema.object({
port: Schema.number('Listening port').default(14510),
});Accessing Configuration
In Functional mode, the config is passed as the second argument to apply:
typescript
export async function apply(ctx: Context, config: MyConfig) {
console.log(config.port);
}In Decorator mode, the config is passed as the second argument to the constructor:
typescript
import { Plugin } from '@yumerijs/decorator';
@Plugin
export default class MyPlugin {
constructor(ctx: Context, private config: MyConfig) {
console.log(this.config.port);
}
}Schema Methods
Schema.string/number/boolean: Basic typesSchema.array(inner): Array typesSchema.object(properties): Object typesSchema.enum(values): Enumerationsschema.required(): Mark as requiredschema.default(value): Set a default value
