@imqueue/rpc
Version:
RPC-like client-service implementation over messaging queue
65 lines (64 loc) • 1.42 kB
TypeScript
export interface Thunk {
(): any;
}
/**
* Implements '@property' decorator factory
* This is used to specify complex service types to be exposed
*
* @example
* ~~~typescript
* import { property, expose, IMQService } from '@imqueue/rpc';
*
* class Address {
* @property('string')
* country: string;
*
* @property('string')
* city: string;
*
* @property('string')
* address: string;
*
* @property('string', true)
* zipCode?: string; // this is optional
* }
*
* class User {
* @property('string')
* firstName: string;
*
* @property('string')
* lastName: string;
*
* @property('string')
* email: string;
*
* @property('Array<Address>', true)
* address?: Array<Address>;
* }
*
* // now we can use those complex types as service methods args
* // and them will be properly exposed to service clients
*
* class UserService extends IMQService {
*
* @expose()
* public save(user: User) {
* // do smth with given user data to persis it
* }
*
* @expose()
* public find(id: number): User {
* // find and return user
* }
*
* }
* ~~~
*
* @return {(
* target: any,
* methodName: (string),
* descriptor: TypedPropertyDescriptor<(...args: any[]) => any>
* ) => void}
*/
export declare function property(type: string | Thunk | any, isOptional?: boolean): any;