Passed
Push — main ( b29f4f...6a3653 )
by Lorenzo
01:09 queued 13s
created

Setup.ts ➔ Setup   A

Complexity

Conditions 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 15
rs 9.9
c 0
b 0
f 0
ccs 5
cts 5
cp 1
cc 1
crap 1
1
import { ExpressBean } from '@/ExpressBeansTypes';
2
import { logger, registeredMethods } from '@/decorators';
3
4
/**
5
   * Hook a function to initialization phase.
6
   * @decorator
7
   */
8
export function Setup<This>(
9
  method: () => any,
10
  context: ClassMethodDecoratorContext<This, () => any>,
11
) {
12 2
  setImmediate(() => {
13 2
    const bean = registeredMethods.get(method) as ExpressBean;
14 2
    logger.debug(`Running setup function ${bean.className}.${String(context.name)}`);
15 2
    method.bind(bean)();
16
  });
17 2
  return method;
18
}
19