UNPKG

rpc-typescript

Version:
22 lines (17 loc) 600 B
import { ProxyContext } from "../core/ProxyContext"; import { ProxyMethodConfig } from "../types"; export function ProxyMethod(config?: ProxyMethodConfig): MethodDecorator { const props = config ?? { transport: 'http', httpMethod: 'POST' }; return (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>) => { const ctx = ProxyContext.getContext(props.contextDomain); return ctx.defineMember( props, target, propertyKey, descriptor ); } }