UNPKG

@gabliam/amqp

Version:
170 lines (169 loc) 4.28 kB
import { Message as MessageAmqp } from 'amqplib'; export type HandlerFn = (args: any, msg: MessageAmqp, content: any) => any; export interface RabbitParamDecorator<T = any> { handler: HandlerFn; args: T[]; } export declare const makeRabbitParamDecorator: (handler: HandlerFn) => any; /** * Type of the `Message` decorator / constructor function. */ export interface MessageDecorator { /** * Decorator that marks a parameter to inject Message * * @usageNotes * * ```typescript * @CUnit('test') * @RabbitController('/') * class SampleController { * @RabbitConsumer('test') * hello(@Message() msg: MessageAmqp) { * console.log('Hello'); * } * } * ``` */ (): ParameterDecorator; /** * see the `@Message` decorator. */ new (): any; } export declare const Message: MessageDecorator; /** * Type of the `Content` decorator / constructor function. */ export interface ContentDecorator { /** * Decorator that marks a parameter to inject Content or a part of Content * * You can supply an optional path to extract a part of Content. * Under the hood, use lodash.get * * @usageNotes * * Example with full Content * * ```typescript * @CUnit('test') * @RabbitController('/') * class SampleController { * @RabbitConsumer('test') * hello(@Content() content: any) { * console.log('Hello'); * } * } * ``` * * Example with part of content * * ```typescript * @CUnit('test') * @RabbitController('/') * class SampleController { * @RabbitConsumer('test') * hello(@Content('test.user') content: any) { * console.log('Hello'); * } * } * ``` */ (path?: string): ParameterDecorator; /** * see the `@Content` decorator. */ new (path?: string): any; } export declare const Content: ContentDecorator; /** * Type of the `Properties` decorator / constructor function. */ export interface PropertiesDecorator { /** * Decorator that marks a parameter to inject Properties or a part of Properties * * You can supply an optional path to extract a part of Properties. * Under the hood, use lodash.get * * @usageNotes * * Example with full Properties * * ```typescript * @CUnit('test') * @RabbitController('/') * class SampleController { * @RabbitConsumer('test') * hello(@Properties() properties: any) { * console.log('Hello'); * } * } * ``` * * Example with part of Properties * * ```typescript * @CUnit('test') * @RabbitController('/') * class SampleController { * @RabbitConsumer('test') * hello(@Properties('test.user') properties: any) { * console.log('Hello'); * } * } * ``` */ (path?: string): ParameterDecorator; /** * see the `@Properties` decorator. */ new (path?: string): any; } export declare const Properties: PropertiesDecorator; /** * Type of the `Fields` decorator / constructor function. */ export interface FieldsDecorator { /** * Decorator that marks a parameter to inject Fields or a part of Fields * * You can supply an optional path to extract a part of Fields. * Under the hood, use lodash.get * * @usageNotes * * Example with full Fields * * ```typescript * @CUnit('test') * @RabbitController('/') * class SampleController { * @RabbitConsumer('test') * hello(@Fields() fields: any) { * console.log('Hello'); * } * } * ``` * * Example with part of Fields * * ```typescript * @CUnit('test') * @RabbitController('/') * class SampleController { * @RabbitConsumer('test') * hello(@Fields('test.user') fields: any) { * console.log('Hello'); * } * } * ``` */ (path?: string): ParameterDecorator; /** * see the `@Fields` decorator. */ new (path?: string): any; } export declare const Fields: FieldsDecorator;