All files / common/decorators/core component.decorator.ts

82.61% Statements 19/23
100% Branches 0/0
69.23% Functions 9/13
82.61% Lines 19/23
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 751x 1x           1x 21x               1x 14x     14x             1x                     1x 2x     2x             1x                     1x 2x     2x     1x 11x     11x 11x    
import * as deprecate from 'deprecate';
import * as uuid from 'uuid/v4';
 
/**
 * Defines the injectable class. This class can inject dependencies through constructor.
 * Those dependencies have to belong to the same module.
 */
export function Injectable(): ClassDecorator {
  return (target: object) => {};
}
 
/**
 * @deprecated
 * Defines the Component. The component can inject dependencies through constructor.
 * Those dependencies have to belong to the same module.
 */
export function Component(): ClassDecorator {
  deprecate(
    'The @Component() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.',
  );
  return (target: object) => {};
}
 
/**
 * @deprecated
 * Defines the Pipe. The Pipe should implement the `PipeTransform` interface.
 */
export function Pipe(): ClassDecorator {
  deprecate(
    'The @Pipe() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.',
  );
  return (target: object) => {};
}
 
/**
 * @deprecated
 * Defines the Guard. The Guard should implement the `CanActivate` interface.
 */
export function Guard(): ClassDecorator {
  deprecate(
    'The @Guard() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.',
  );
  return (target: object) => {};
}
 
/**
 * @deprecated
 * Defines the Middleware. The Middleware should implement the `NestMiddleware` interface.
 */
export function Middleware(): ClassDecorator {
  deprecate(
    'The @Middleware() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.',
  );
  return (target: object) => {};
}
 
/**
 * @deprecated
 * Defines the Interceptor. The Interceptor should implement `HttpInterceptor`, `RpcInterceptor` or `WsInterceptor` interface.
 */
export function Interceptor(): ClassDecorator {
  deprecate(
    'The @Interceptor() decorator is deprecated and will be removed within next major release. Use @Injectable() instead.',
  );
  return (target: object) => {};
}
 
export function mixin(mixinClass) {
  Object.defineProperty(mixinClass, 'name', {
    value: uuid(),
  });
  Injectable()(mixinClass);
  return mixinClass;
}