Skip to content

Commit a90570d

Browse files
refactor: move container registration to separate file
1 parent 9b97263 commit a90570d

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/container-registrations.const.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Container } from 'typedi';
2+
import { ConnectionManager } from 'typeorm';
3+
4+
/** This file registers all classes from TypeORM in the default TypeDI container. */
5+
6+
/**
7+
* We need to set imported TypeORM classes before requesting them, otherwise we
8+
* would receive a "ServiceNotFoundError" above TypeDI 0.9.1 from the decorators.
9+
*/
10+
Container.set({ id: ConnectionManager, type: ConnectionManager });

src/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
import { Container as TypeDIContainer } from 'typedi';
2-
import { ConnectionManager } from 'typeorm';
31
import { TypeDIContainerProvider } from './container-provider.class';
42

53
export * from './decorators/inject-connection.decorator';
64
export * from './decorators/inject-manager.decorator';
75
export * from './decorators/inject-repository.decorator';
86

9-
/**
10-
* We need to set imported TypeORM classes before requesting them, otherwise we
11-
* would receive a "ServiceNotFoundError" above TypeDI 0.9.1 from the decorators.
12-
*/
13-
TypeDIContainer.set({ id: ConnectionManager, type: ConnectionManager });
7+
import './container-registrations.const';
148

159
/**
1610
* We export the current container implementation what transforms function

0 commit comments

Comments
 (0)