Interface IResourceMiddlewareDefinition<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies>

interface IResourceMiddlewareDefinition<TConfig, TEnforceInputContract, TEnforceOutputContract, TDependencies> {
    configSchema?: IValidationSchema<TConfig>;
    dependencies?: TDependencies | ((config: TConfig) => TDependencies);
    everywhere?: boolean | ((resource: IResource<any, any, any, any, any, TagType[], ResourceMiddlewareAttachmentType[]>) => boolean);
    id: string;
    meta?: IMiddlewareMeta;
    run: ((input: IResourceMiddlewareExecutionInput<TEnforceInputContract extends void
        ? any
        : TEnforceInputContract, TEnforceOutputContract extends void
        ? any
        : TEnforceOutputContract>, dependencies: DependencyValuesType<TDependencies>, config: TConfig) => Promise<any>);
    tags?: TagType[];
}

Type Parameters

  • TConfig = any
  • TEnforceInputContract = void
  • TEnforceOutputContract = void
  • TDependencies extends DependencyMapType = any

Hierarchy (view full)

Properties

configSchema?: IValidationSchema<TConfig>

Optional validation schema for runtime config validation. When provided, middleware config will be validated when .with() is called.

dependencies?: TDependencies | ((config: TConfig) => TDependencies)

Static or lazy dependency map.

everywhere?: boolean | ((resource: IResource<any, any, any, any, any, TagType[], ResourceMiddlewareAttachmentType[]>) => boolean)
id: string
run: ((input: IResourceMiddlewareExecutionInput<TEnforceInputContract extends void
    ? any
    : TEnforceInputContract, TEnforceOutputContract extends void
    ? any
    : TEnforceOutputContract>, dependencies: DependencyValuesType<TDependencies>, config: TConfig) => Promise<any>)

The middleware body, called with resource execution input.

tags?: TagType[]