UNPKG

fusion-plugin-rpc

Version:

Fetch data on the server and client with an RPC style interface.

30 lines (25 loc) 944 B
/** Copyright (c) 2018 Uber Technologies, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import {createToken} from 'fusion-core'; import type {Token, Context} from 'fusion-core'; import type {Options} from 'koa-bodyparser'; import type {RPCConfigType, RPCServiceType} from './types'; export const RPCToken: Token<RPCServiceType> = createToken('RPCToken'); export type HandlerType = { [x: string]: (...args: any) => any; }; export const RPCHandlersToken: Token<HandlerType> = createToken('RPCHandlersToken'); export const BodyParserOptionsToken: Token<Options> = createToken( 'BodyParserOptionsToken' ); export const RPCHandlersConfigToken: Token<RPCConfigType> = createToken( 'RPCHandlersConfigToken' ); export const RPCQueryParamsToken: Token<{ from: (ctx: Context) => Array<[string, string]>; }> = createToken('RPCQueryParamsToken');