import { StubContext } from "../core/StubContext";
import { StubMethodConfig } from "../types";


export function StubMethod(config?: StubMethodConfig): MethodDecorator {

    const props = config ?? {
        transport: 'http',
        httpMethod: 'POST'
    };

    return (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>) => {

        const ctx = StubContext.getContext(props.contextDomain);

        return ctx.defineMember(
            props,
            target,
            propertyKey,
            descriptor
        );
    }
}