File size: 869 Bytes
b410f5c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import type { ModuleInterface } from '@n8n/decorators';
import { BackendModule, OnShutdown } from '@n8n/decorators';
import { Container } from '@n8n/di';

@BackendModule({ name: 'my-feature' })
export class MyFeatureModule implements ModuleInterface {
	async init() {
		await import('./my-feature.controller');

		const { MyFeatureService } = await import('./my-feature.service');
		Container.get(MyFeatureService).start();
	}

	@OnShutdown()
	async shutdown() {
		const { MyFeatureService } = await import('./my-feature.service');

		await Container.get(MyFeatureService).shutdown();
	}

	async entities() {
		const { MyFeatureEntity } = await import('./my-feature.entity');
		
		return [MyFeatureEntity];
	}

	async context() {
		const { MyFeatureService } = await import('./my-feature.service');
		
		return { myFeatureProxy: Container.get(MyFeatureService) };
	}
}