Conditions | 1 |
Total Lines | 17 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 1 |
Changes | 0 |
1 | import { ExpressBean } from '@/ExpressBeansTypes'; |
||
4 | |||
5 | /** |
||
6 | * Hook a function right before the application is destroyed |
||
7 | * @decorator |
||
8 | */ |
||
9 | 5 | export function Shutdown<This>( |
|
10 | method: () => any, |
||
11 | context: ClassMethodDecoratorContext<This, () => any>, |
||
12 | ) { |
||
13 | 4 | logger.debug(`Registering pre destroy function ${String(context.name)}`); |
|
14 | 4 | Executor.setExecution('routing', () => { |
|
15 | 4 | const bean = registeredMethods.get(method) as ExpressBean; |
|
16 | 4 | logger.debug(`Initializing ${bean._className}.${String(context.name)} as pre destroy function`); |
|
17 | 9 | Executor.setExecution('exit', () => method.bind(bean)()); |
|
18 | }); |
||
19 | |||
20 | 4 | return method; |
|
21 | } |
||
22 |