UNPKG

@redpc/core

Version:

Remoted Procedure Call (RedPC) - A javascript RPC library written with TypeScript

26 lines (18 loc) 716 B
import { scrapeConventionalSuffixes } from "helpers"; import { ProxyContext, ProxyContextMutator } from "../core/ProxyContext"; import { ProxyContractConfig } from "../types"; // const DefaultConfig: ProxyContractConfig = { // }; export function ProxyContract(config?: ProxyContractConfig): ClassDecorator { return <TFunction extends Function>(constructor: TFunction) => { const props = { path: scrapeConventionalSuffixes(constructor.name), ...config }; const ctx = ProxyContext.getContext(props.contextDomain) as ProxyContextMutator; return ctx.defineContract( props, constructor ); } }