forked from Sairyss/domain-driven-hexagon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.module.ts
55 lines (46 loc) · 2.04 KB
/
user.module.ts
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Logger, Module, Provider } from '@nestjs/common';
import { UserRepository } from './database/user.repository';
import { CreateUserHttpController } from './commands/create-user/create-user.http.controller';
import { DeleteUserHttpController } from './commands/delete-user/delete-user.http-controller';
import { CreateUserCliController } from './commands/create-user/create-user.cli.controller';
import { FindUsersHttpController } from './queries/find-users/find-users.http.controller';
import { CreateUserMessageController } from './commands/create-user/create-user.message.controller';
import { CreateUserGraphqlResolver } from './commands/create-user/graphql-example/create-user.graphql-resolver';
import { CreateUserService } from './commands/create-user/create-user.service';
import { DeleteUserService } from './commands/delete-user/delete-user.service';
import { FindUsersQueryHandler } from './queries/find-users/find-users.query-handler';
import { UserMapper } from './user.mapper';
import { CqrsModule } from '@nestjs/cqrs';
import { USER_REPOSITORY } from './user.di-tokens';
import { FindUsersGraphqlResolver } from './queries/find-users/find-users.graphql-resolver';
const httpControllers = [
CreateUserHttpController,
DeleteUserHttpController,
FindUsersHttpController,
];
const messageControllers = [CreateUserMessageController];
const cliControllers: Provider[] = [CreateUserCliController];
const graphqlResolvers: Provider[] = [
CreateUserGraphqlResolver,
FindUsersGraphqlResolver,
];
const commandHandlers: Provider[] = [CreateUserService, DeleteUserService];
const queryHandlers: Provider[] = [FindUsersQueryHandler];
const mappers: Provider[] = [UserMapper];
const repositories: Provider[] = [
{ provide: USER_REPOSITORY, useClass: UserRepository },
];
@Module({
imports: [CqrsModule],
controllers: [...httpControllers, ...messageControllers],
providers: [
Logger,
...cliControllers,
...repositories,
...graphqlResolvers,
...commandHandlers,
...queryHandlers,
...mappers,
],
})
export class UserModule {}