|
|
|
## Module
|
|
|
|
|
|
|
|
Modules are used to organize the application structure. A basic module in our application looks something like this:
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
@Module({
|
|
|
|
imports: [TypeOrmModule.forFeature([PersonEntity])],
|
|
|
|
controllers: [UserController],
|
|
|
|
providers: [UserService]
|
|
|
|
})
|
|
|
|
export class UserModule {}
|
|
|
|
```
|
|
|
|
|
|
|
|
Syntax is very simple: all _Entities_ you need to inject in your services, you need to import in `TypeOrmModule.forFeature`. Controllers and providers contain all the controllers and services in module context. If you need to import a module in a module, you need to add it to the imports, after the TypeOrm array:
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
@Module({
|
|
|
|
imports: [
|
|
|
|
TypeOrmModule.forFeature([
|
|
|
|
ScoreEntity,
|
|
|
|
ObjectivePointEntity,
|
|
|
|
ObjectivePoint_HistoryEntity,
|
|
|
|
FactionEntity
|
|
|
|
]),
|
|
|
|
NotificationModule
|
|
|
|
],
|
|
|
|
controllers: [ScoreController],
|
|
|
|
providers: [ScoreService]
|
|
|
|
})
|
|
|
|
export class ScoreModule {}
|
|
|
|
``` |