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

src/decorators/Setup.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 19
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 12
mnd 0
bc 0
fnc 1
dl 0
loc 19
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
ccs 5
cts 5
cp 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A Setup.ts ➔ Setup 0 15 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