rxstack/rxstack

View on GitHub
packages/core/src/kernel/metadata/decorators.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import {HttpMethod} from '../interfaces';
import {httpMetadataStorage, webSocketMetadataStorage} from './metadata-storage';

export function Http<T>(httpMethod: HttpMethod, path: string, name: string): MethodDecorator {
  return function (target: Function, propertyKey: string): void {
    httpMetadataStorage.add({
      'target': target.constructor,
      'name': name,
      'path': path,
      'httpMethod': httpMethod,
      'propertyKey': propertyKey,
      'transport': 'HTTP'
    });
  };
}

export function WebSocket<T>(eventName: string): MethodDecorator {
  return function (target: Function, propertyKey: string): void {
    webSocketMetadataStorage.add({
      'target': target.constructor,
      'name': eventName,
      'propertyKey': propertyKey,
      'transport': 'SOCKET'
    });
  };
}