# All files / common/utils bind-resolve-values.util.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 3/3
100% Lines 9/9

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22

    1x

    1x

    2x
    2x

    1x

    2x
    2x
    2x
    2x

     import { Constructor } from './merge-with-values.util';
    import { NestMiddleware } from '../interfaces/middleware/nest-middleware.interface';
    import { Injectable } from '../decorators/core/component.decorator';

    export const BindResolveMiddlewareValues = <
      T extends Constructor<NestMiddleware>
    >(
      data: Array<any>,
    ) => {
      return (Metatype: T): any => {
        const type = class extends Metatype {
          public resolve() {
            return super.resolve(...data);
          }
        };
        const token = Metatype.name + JSON.stringify(data);
        Object.defineProperty(type, 'name', { value: token });
        Injectable()(type);
        return type;
      };
    };