# All files / websockets/utils subscribe-message.decorator.ts

100% Statements 6/6
100% Branches 0/0
100% Functions 2/2
100% Lines 6/6

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    151x

    1x

    3x
    3x
    3x
    3x

     import { MESSAGE_MAPPING_METADATA, MESSAGE_METADATA } from '../constants';

    /**
     * Subscribes to messages that fulfils chosen pattern.
     */
    export const SubscribeMessage = <T = string>(
      message: T,
    ): MethodDecorator => {
      return (target, key, descriptor: PropertyDescriptor) => {
        Reflect.defineMetadata(MESSAGE_MAPPING_METADATA, true, descriptor.value);
        Reflect.defineMetadata(MESSAGE_METADATA, message, descriptor.value);
        return descriptor;
      };
    };