Total Complexity | 1 |
Complexity/F | 1 |
Lines of Code | 19 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 0 |
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 |