@hedhog/admin 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{hedhog.yaml → bkp.hedhog.yaml} +1012 -814
- package/dist/auth/consts/body.js +23 -23
- package/package.json +43 -43
- package/src/admin.module.ts +37 -37
- package/src/auth/auth.controller.ts +72 -72
- package/src/auth/auth.module.ts +39 -39
- package/src/auth/auth.service.spec.ts +196 -196
- package/src/auth/auth.service.ts +234 -234
- package/src/auth/consts/body.ts +26 -26
- package/src/auth/consts/subject.ts +1 -1
- package/src/auth/dto/forget.dto.ts +6 -6
- package/src/auth/dto/login.dto.ts +15 -15
- package/src/auth/dto/otp.dto.ts +11 -11
- package/src/auth/dto/reset.dto.ts +14 -14
- package/src/auth/enums/multifactor-type.enum.ts +4 -4
- package/src/auth/guards/auth.guard.ts +50 -50
- package/src/auth/types/user.type.ts +8 -8
- package/src/dto/delete.dto.ts +8 -8
- package/src/dto/update-ids.dto.ts +9 -9
- package/src/index.ts +20 -20
- package/src/menu/dto/create.dto.ts +25 -25
- package/src/menu/dto/order.dto.ts +8 -8
- package/src/menu/dto/update.dto.ts +19 -19
- package/src/menu/menu.controller.ts +105 -105
- package/src/menu/menu.module.ts +18 -18
- package/src/menu/menu.service.spec.ts +247 -247
- package/src/menu/menu.service.ts +263 -263
- package/src/role/dto/create.dto.ts +7 -7
- package/src/role/dto/update.dto.ts +4 -4
- package/src/role/guards/role.guard.ts +123 -123
- package/src/role/role.controller.ts +126 -126
- package/src/role/role.module.ts +28 -28
- package/src/role/role.service.spec.ts +417 -417
- package/src/role/role.service.ts +289 -289
- package/src/route/dto/create.dto.ts +13 -13
- package/src/route/dto/update.dto.ts +15 -15
- package/src/route/route.controller.ts +91 -91
- package/src/route/route.module.ts +18 -18
- package/src/route/route.service.spec.ts +300 -300
- package/src/route/route.service.ts +164 -164
- package/src/screen/dto/create.dto.ts +11 -11
- package/src/screen/dto/update.dto.ts +19 -19
- package/src/screen/screen.controller.ts +93 -93
- package/src/screen/screen.module.ts +18 -18
- package/src/screen/screen.service.spec.ts +298 -298
- package/src/screen/screen.service.ts +179 -179
- package/src/types/http-method.ts +8 -8
- package/src/user/constants/user.constants.ts +1 -1
- package/src/user/dto/create.dto.ts +24 -24
- package/src/user/dto/update.dto.ts +41 -41
- package/src/user/user.controller.ts +75 -75
- package/src/user/user.module.ts +18 -18
- package/src/user/user.service.spec.ts +294 -294
- package/src/user/user.service.ts +129 -129
@@ -1,123 +1,123 @@
|
|
1
|
-
import { IS_PUBLIC_KEY, WITH_ROLE } from '@hedhog/core';
|
2
|
-
import { PrismaService } from '@hedhog/prisma';
|
3
|
-
import {
|
4
|
-
CanActivate,
|
5
|
-
ExecutionContext,
|
6
|
-
forwardRef,
|
7
|
-
Inject,
|
8
|
-
Injectable,
|
9
|
-
RequestMethod,
|
10
|
-
UnauthorizedException,
|
11
|
-
} from '@nestjs/common';
|
12
|
-
import { METHOD_METADATA } from '@nestjs/common/constants';
|
13
|
-
import { Reflector } from '@nestjs/core';
|
14
|
-
import { Request } from 'express';
|
15
|
-
|
16
|
-
@Injectable()
|
17
|
-
export class RoleGuard implements CanActivate {
|
18
|
-
constructor(
|
19
|
-
private reflector: Reflector,
|
20
|
-
@Inject(forwardRef(() => PrismaService))
|
21
|
-
private readonly prisma: PrismaService,
|
22
|
-
) {}
|
23
|
-
|
24
|
-
async canActivate(context: ExecutionContext): Promise<boolean> {
|
25
|
-
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
|
26
|
-
context.getHandler(),
|
27
|
-
context.getClass(),
|
28
|
-
]);
|
29
|
-
|
30
|
-
if (isPublic) {
|
31
|
-
return true;
|
32
|
-
}
|
33
|
-
|
34
|
-
const withRole = this.reflector.getAllAndOverride<boolean>(WITH_ROLE, [
|
35
|
-
context.getHandler(),
|
36
|
-
context.getClass(),
|
37
|
-
]);
|
38
|
-
|
39
|
-
if (!withRole) {
|
40
|
-
return true;
|
41
|
-
}
|
42
|
-
|
43
|
-
const request = context.switchToHttp().getRequest<Request>();
|
44
|
-
const controller = context.getClass();
|
45
|
-
const handler = context.getHandler();
|
46
|
-
const controllerPath = this.reflector.get<string>('path', controller) || '';
|
47
|
-
const methodPath = this.reflector.get<string>('path', handler) || '';
|
48
|
-
|
49
|
-
const requestMethod = this.reflector.get<RequestMethod>(
|
50
|
-
METHOD_METADATA,
|
51
|
-
handler,
|
52
|
-
);
|
53
|
-
|
54
|
-
let fullPath = `/${controllerPath}/${methodPath}`.replace(/\/+/g, '/');
|
55
|
-
|
56
|
-
if (fullPath.endsWith('/')) {
|
57
|
-
fullPath = fullPath.slice(0, -1);
|
58
|
-
}
|
59
|
-
|
60
|
-
const token = this.extractTokenFromHeader(request);
|
61
|
-
|
62
|
-
if (!token) {
|
63
|
-
throw new UnauthorizedException();
|
64
|
-
}
|
65
|
-
|
66
|
-
const userId = (request as any)?.auth?.user?.id;
|
67
|
-
|
68
|
-
let httpMethod: any;
|
69
|
-
switch (requestMethod) {
|
70
|
-
case RequestMethod.GET:
|
71
|
-
httpMethod = 'GET';
|
72
|
-
break;
|
73
|
-
case RequestMethod.POST:
|
74
|
-
httpMethod = 'POST';
|
75
|
-
break;
|
76
|
-
case RequestMethod.PUT:
|
77
|
-
httpMethod = 'PUT';
|
78
|
-
break;
|
79
|
-
case RequestMethod.DELETE:
|
80
|
-
httpMethod = 'DELETE';
|
81
|
-
break;
|
82
|
-
case RequestMethod.PATCH:
|
83
|
-
httpMethod = 'PATCH';
|
84
|
-
break;
|
85
|
-
case RequestMethod.OPTIONS:
|
86
|
-
httpMethod = 'OPTIONS';
|
87
|
-
break;
|
88
|
-
case RequestMethod.HEAD:
|
89
|
-
httpMethod = 'HEAD';
|
90
|
-
break;
|
91
|
-
case RequestMethod.ALL:
|
92
|
-
httpMethod = 'ALL';
|
93
|
-
break;
|
94
|
-
}
|
95
|
-
|
96
|
-
console.log({ fullPath, httpMethod });
|
97
|
-
|
98
|
-
const route = await this.prisma.route.count({
|
99
|
-
where: {
|
100
|
-
method: httpMethod,
|
101
|
-
url: fullPath,
|
102
|
-
role_route: {
|
103
|
-
some: {
|
104
|
-
role: {
|
105
|
-
role_user: {
|
106
|
-
some: {
|
107
|
-
user_id: Number(userId),
|
108
|
-
},
|
109
|
-
},
|
110
|
-
},
|
111
|
-
},
|
112
|
-
},
|
113
|
-
},
|
114
|
-
});
|
115
|
-
|
116
|
-
return route === 1;
|
117
|
-
}
|
118
|
-
|
119
|
-
private extractTokenFromHeader(request: Request): string | undefined {
|
120
|
-
const [type, token] = request.headers.authorization?.split(' ') ?? [];
|
121
|
-
return type === 'Bearer' ? token : undefined;
|
122
|
-
}
|
123
|
-
}
|
1
|
+
import { IS_PUBLIC_KEY, WITH_ROLE } from '@hedhog/core';
|
2
|
+
import { PrismaService } from '@hedhog/prisma';
|
3
|
+
import {
|
4
|
+
CanActivate,
|
5
|
+
ExecutionContext,
|
6
|
+
forwardRef,
|
7
|
+
Inject,
|
8
|
+
Injectable,
|
9
|
+
RequestMethod,
|
10
|
+
UnauthorizedException,
|
11
|
+
} from '@nestjs/common';
|
12
|
+
import { METHOD_METADATA } from '@nestjs/common/constants';
|
13
|
+
import { Reflector } from '@nestjs/core';
|
14
|
+
import { Request } from 'express';
|
15
|
+
|
16
|
+
@Injectable()
|
17
|
+
export class RoleGuard implements CanActivate {
|
18
|
+
constructor(
|
19
|
+
private reflector: Reflector,
|
20
|
+
@Inject(forwardRef(() => PrismaService))
|
21
|
+
private readonly prisma: PrismaService,
|
22
|
+
) {}
|
23
|
+
|
24
|
+
async canActivate(context: ExecutionContext): Promise<boolean> {
|
25
|
+
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
|
26
|
+
context.getHandler(),
|
27
|
+
context.getClass(),
|
28
|
+
]);
|
29
|
+
|
30
|
+
if (isPublic) {
|
31
|
+
return true;
|
32
|
+
}
|
33
|
+
|
34
|
+
const withRole = this.reflector.getAllAndOverride<boolean>(WITH_ROLE, [
|
35
|
+
context.getHandler(),
|
36
|
+
context.getClass(),
|
37
|
+
]);
|
38
|
+
|
39
|
+
if (!withRole) {
|
40
|
+
return true;
|
41
|
+
}
|
42
|
+
|
43
|
+
const request = context.switchToHttp().getRequest<Request>();
|
44
|
+
const controller = context.getClass();
|
45
|
+
const handler = context.getHandler();
|
46
|
+
const controllerPath = this.reflector.get<string>('path', controller) || '';
|
47
|
+
const methodPath = this.reflector.get<string>('path', handler) || '';
|
48
|
+
|
49
|
+
const requestMethod = this.reflector.get<RequestMethod>(
|
50
|
+
METHOD_METADATA,
|
51
|
+
handler,
|
52
|
+
);
|
53
|
+
|
54
|
+
let fullPath = `/${controllerPath}/${methodPath}`.replace(/\/+/g, '/');
|
55
|
+
|
56
|
+
if (fullPath.endsWith('/')) {
|
57
|
+
fullPath = fullPath.slice(0, -1);
|
58
|
+
}
|
59
|
+
|
60
|
+
const token = this.extractTokenFromHeader(request);
|
61
|
+
|
62
|
+
if (!token) {
|
63
|
+
throw new UnauthorizedException();
|
64
|
+
}
|
65
|
+
|
66
|
+
const userId = (request as any)?.auth?.user?.id;
|
67
|
+
|
68
|
+
let httpMethod: any;
|
69
|
+
switch (requestMethod) {
|
70
|
+
case RequestMethod.GET:
|
71
|
+
httpMethod = 'GET';
|
72
|
+
break;
|
73
|
+
case RequestMethod.POST:
|
74
|
+
httpMethod = 'POST';
|
75
|
+
break;
|
76
|
+
case RequestMethod.PUT:
|
77
|
+
httpMethod = 'PUT';
|
78
|
+
break;
|
79
|
+
case RequestMethod.DELETE:
|
80
|
+
httpMethod = 'DELETE';
|
81
|
+
break;
|
82
|
+
case RequestMethod.PATCH:
|
83
|
+
httpMethod = 'PATCH';
|
84
|
+
break;
|
85
|
+
case RequestMethod.OPTIONS:
|
86
|
+
httpMethod = 'OPTIONS';
|
87
|
+
break;
|
88
|
+
case RequestMethod.HEAD:
|
89
|
+
httpMethod = 'HEAD';
|
90
|
+
break;
|
91
|
+
case RequestMethod.ALL:
|
92
|
+
httpMethod = 'ALL';
|
93
|
+
break;
|
94
|
+
}
|
95
|
+
|
96
|
+
console.log({ fullPath, httpMethod });
|
97
|
+
|
98
|
+
const route = await this.prisma.route.count({
|
99
|
+
where: {
|
100
|
+
method: httpMethod,
|
101
|
+
url: fullPath,
|
102
|
+
role_route: {
|
103
|
+
some: {
|
104
|
+
role: {
|
105
|
+
role_user: {
|
106
|
+
some: {
|
107
|
+
user_id: Number(userId),
|
108
|
+
},
|
109
|
+
},
|
110
|
+
},
|
111
|
+
},
|
112
|
+
},
|
113
|
+
},
|
114
|
+
});
|
115
|
+
|
116
|
+
return route === 1;
|
117
|
+
}
|
118
|
+
|
119
|
+
private extractTokenFromHeader(request: Request): string | undefined {
|
120
|
+
const [type, token] = request.headers.authorization?.split(' ') ?? [];
|
121
|
+
return type === 'Bearer' ? token : undefined;
|
122
|
+
}
|
123
|
+
}
|
@@ -1,126 +1,126 @@
|
|
1
|
-
import { Pagination } from '@hedhog/pagination';
|
2
|
-
import {
|
3
|
-
Body,
|
4
|
-
Controller,
|
5
|
-
Delete,
|
6
|
-
Get,
|
7
|
-
Inject,
|
8
|
-
Param,
|
9
|
-
ParseIntPipe,
|
10
|
-
Patch,
|
11
|
-
Post,
|
12
|
-
forwardRef,
|
13
|
-
} from '@nestjs/common';
|
14
|
-
import { DeleteDTO } from '../dto/delete.dto';
|
15
|
-
import { UpdateIdsDTO } from '../dto/update-ids.dto';
|
16
|
-
import { Locale } from '@hedhog/locale';
|
17
|
-
import { Role } from '@hedhog/core';
|
18
|
-
import { CreateDTO } from './dto/create.dto';
|
19
|
-
import { UpdateDTO } from './dto/update.dto';
|
20
|
-
import { RoleService } from './role.service';
|
21
|
-
|
22
|
-
@Role()
|
23
|
-
@Controller('role')
|
24
|
-
export class RoleController {
|
25
|
-
constructor(
|
26
|
-
@Inject(forwardRef(() => RoleService))
|
27
|
-
private readonly roleService: RoleService,
|
28
|
-
) {}
|
29
|
-
|
30
|
-
@Get()
|
31
|
-
async list(@Pagination() paginationParams, @Locale() locale) {
|
32
|
-
return this.roleService.list(locale, paginationParams);
|
33
|
-
}
|
34
|
-
|
35
|
-
@Get(':roleId/user')
|
36
|
-
async listUsers(
|
37
|
-
@Pagination() paginationParams,
|
38
|
-
@Param('roleId', ParseIntPipe) roleId: number,
|
39
|
-
) {
|
40
|
-
return this.roleService.listUsers(roleId, paginationParams);
|
41
|
-
}
|
42
|
-
|
43
|
-
@Get(':roleId/menu')
|
44
|
-
async listMenus(
|
45
|
-
@Pagination() paginationParams,
|
46
|
-
@Param('roleId', ParseIntPipe) roleId: number,
|
47
|
-
@Locale() locale,
|
48
|
-
) {
|
49
|
-
return this.roleService.listMenus(locale, roleId, paginationParams);
|
50
|
-
}
|
51
|
-
|
52
|
-
@Get(':roleId/route')
|
53
|
-
async listRoutes(
|
54
|
-
@Pagination() paginationParams,
|
55
|
-
@Param('roleId', ParseIntPipe) roleId: number,
|
56
|
-
) {
|
57
|
-
return this.roleService.listRoutes(roleId, paginationParams);
|
58
|
-
}
|
59
|
-
|
60
|
-
@Get(':roleId/screen')
|
61
|
-
async listScreens(
|
62
|
-
@Pagination() paginationParams,
|
63
|
-
@Param('roleId', ParseIntPipe) roleId: number,
|
64
|
-
@Locale() locale,
|
65
|
-
) {
|
66
|
-
return this.roleService.listScreens(locale, roleId, paginationParams);
|
67
|
-
}
|
68
|
-
|
69
|
-
@Patch(':roleId/user')
|
70
|
-
async updateUsers(
|
71
|
-
@Param('roleId', ParseIntPipe) roleId: number,
|
72
|
-
@Body() data: UpdateIdsDTO,
|
73
|
-
) {
|
74
|
-
return this.roleService.updateUsers(roleId, data);
|
75
|
-
}
|
76
|
-
|
77
|
-
@Patch(':roleId/menu')
|
78
|
-
async updateMenus(
|
79
|
-
@Param('roleId', ParseIntPipe) roleId: number,
|
80
|
-
@Body() data: UpdateIdsDTO,
|
81
|
-
) {
|
82
|
-
return this.roleService.updateMenus(roleId, data);
|
83
|
-
}
|
84
|
-
|
85
|
-
@Patch(':roleId/route')
|
86
|
-
async updateRoutes(
|
87
|
-
@Param('roleId', ParseIntPipe) roleId: number,
|
88
|
-
@Body() data: UpdateIdsDTO,
|
89
|
-
) {
|
90
|
-
return this.roleService.updateRoutes(roleId, data);
|
91
|
-
}
|
92
|
-
|
93
|
-
@Patch(':roleId/screen')
|
94
|
-
async updateScreens(
|
95
|
-
@Param('roleId', ParseIntPipe) roleId: number,
|
96
|
-
@Body() data: UpdateIdsDTO,
|
97
|
-
) {
|
98
|
-
return this.roleService.updateScreens(roleId, data);
|
99
|
-
}
|
100
|
-
|
101
|
-
@Get(':roleId')
|
102
|
-
async show(@Param('roleId', ParseIntPipe) roleId: number, @Locale() locale) {
|
103
|
-
return this.roleService.get(locale, roleId);
|
104
|
-
}
|
105
|
-
|
106
|
-
@Post()
|
107
|
-
async create(@Body() data: CreateDTO) {
|
108
|
-
return this.roleService.create(data);
|
109
|
-
}
|
110
|
-
|
111
|
-
@Patch(':roleId')
|
112
|
-
async update(
|
113
|
-
@Param('roleId', ParseIntPipe) roleId: number,
|
114
|
-
@Body() data: UpdateDTO,
|
115
|
-
) {
|
116
|
-
return this.roleService.update({
|
117
|
-
id: roleId,
|
118
|
-
data,
|
119
|
-
});
|
120
|
-
}
|
121
|
-
|
122
|
-
@Delete()
|
123
|
-
async delete(@Body() data: DeleteDTO) {
|
124
|
-
return this.roleService.delete(data);
|
125
|
-
}
|
126
|
-
}
|
1
|
+
import { Pagination } from '@hedhog/pagination';
|
2
|
+
import {
|
3
|
+
Body,
|
4
|
+
Controller,
|
5
|
+
Delete,
|
6
|
+
Get,
|
7
|
+
Inject,
|
8
|
+
Param,
|
9
|
+
ParseIntPipe,
|
10
|
+
Patch,
|
11
|
+
Post,
|
12
|
+
forwardRef,
|
13
|
+
} from '@nestjs/common';
|
14
|
+
import { DeleteDTO } from '../dto/delete.dto';
|
15
|
+
import { UpdateIdsDTO } from '../dto/update-ids.dto';
|
16
|
+
import { Locale } from '@hedhog/locale';
|
17
|
+
import { Role } from '@hedhog/core';
|
18
|
+
import { CreateDTO } from './dto/create.dto';
|
19
|
+
import { UpdateDTO } from './dto/update.dto';
|
20
|
+
import { RoleService } from './role.service';
|
21
|
+
|
22
|
+
@Role()
|
23
|
+
@Controller('role')
|
24
|
+
export class RoleController {
|
25
|
+
constructor(
|
26
|
+
@Inject(forwardRef(() => RoleService))
|
27
|
+
private readonly roleService: RoleService,
|
28
|
+
) {}
|
29
|
+
|
30
|
+
@Get()
|
31
|
+
async list(@Pagination() paginationParams, @Locale() locale) {
|
32
|
+
return this.roleService.list(locale, paginationParams);
|
33
|
+
}
|
34
|
+
|
35
|
+
@Get(':roleId/user')
|
36
|
+
async listUsers(
|
37
|
+
@Pagination() paginationParams,
|
38
|
+
@Param('roleId', ParseIntPipe) roleId: number,
|
39
|
+
) {
|
40
|
+
return this.roleService.listUsers(roleId, paginationParams);
|
41
|
+
}
|
42
|
+
|
43
|
+
@Get(':roleId/menu')
|
44
|
+
async listMenus(
|
45
|
+
@Pagination() paginationParams,
|
46
|
+
@Param('roleId', ParseIntPipe) roleId: number,
|
47
|
+
@Locale() locale,
|
48
|
+
) {
|
49
|
+
return this.roleService.listMenus(locale, roleId, paginationParams);
|
50
|
+
}
|
51
|
+
|
52
|
+
@Get(':roleId/route')
|
53
|
+
async listRoutes(
|
54
|
+
@Pagination() paginationParams,
|
55
|
+
@Param('roleId', ParseIntPipe) roleId: number,
|
56
|
+
) {
|
57
|
+
return this.roleService.listRoutes(roleId, paginationParams);
|
58
|
+
}
|
59
|
+
|
60
|
+
@Get(':roleId/screen')
|
61
|
+
async listScreens(
|
62
|
+
@Pagination() paginationParams,
|
63
|
+
@Param('roleId', ParseIntPipe) roleId: number,
|
64
|
+
@Locale() locale,
|
65
|
+
) {
|
66
|
+
return this.roleService.listScreens(locale, roleId, paginationParams);
|
67
|
+
}
|
68
|
+
|
69
|
+
@Patch(':roleId/user')
|
70
|
+
async updateUsers(
|
71
|
+
@Param('roleId', ParseIntPipe) roleId: number,
|
72
|
+
@Body() data: UpdateIdsDTO,
|
73
|
+
) {
|
74
|
+
return this.roleService.updateUsers(roleId, data);
|
75
|
+
}
|
76
|
+
|
77
|
+
@Patch(':roleId/menu')
|
78
|
+
async updateMenus(
|
79
|
+
@Param('roleId', ParseIntPipe) roleId: number,
|
80
|
+
@Body() data: UpdateIdsDTO,
|
81
|
+
) {
|
82
|
+
return this.roleService.updateMenus(roleId, data);
|
83
|
+
}
|
84
|
+
|
85
|
+
@Patch(':roleId/route')
|
86
|
+
async updateRoutes(
|
87
|
+
@Param('roleId', ParseIntPipe) roleId: number,
|
88
|
+
@Body() data: UpdateIdsDTO,
|
89
|
+
) {
|
90
|
+
return this.roleService.updateRoutes(roleId, data);
|
91
|
+
}
|
92
|
+
|
93
|
+
@Patch(':roleId/screen')
|
94
|
+
async updateScreens(
|
95
|
+
@Param('roleId', ParseIntPipe) roleId: number,
|
96
|
+
@Body() data: UpdateIdsDTO,
|
97
|
+
) {
|
98
|
+
return this.roleService.updateScreens(roleId, data);
|
99
|
+
}
|
100
|
+
|
101
|
+
@Get(':roleId')
|
102
|
+
async show(@Param('roleId', ParseIntPipe) roleId: number, @Locale() locale) {
|
103
|
+
return this.roleService.get(locale, roleId);
|
104
|
+
}
|
105
|
+
|
106
|
+
@Post()
|
107
|
+
async create(@Body() data: CreateDTO) {
|
108
|
+
return this.roleService.create(data);
|
109
|
+
}
|
110
|
+
|
111
|
+
@Patch(':roleId')
|
112
|
+
async update(
|
113
|
+
@Param('roleId', ParseIntPipe) roleId: number,
|
114
|
+
@Body() data: UpdateDTO,
|
115
|
+
) {
|
116
|
+
return this.roleService.update({
|
117
|
+
id: roleId,
|
118
|
+
data,
|
119
|
+
});
|
120
|
+
}
|
121
|
+
|
122
|
+
@Delete()
|
123
|
+
async delete(@Body() data: DeleteDTO) {
|
124
|
+
return this.roleService.delete(data);
|
125
|
+
}
|
126
|
+
}
|
package/src/role/role.module.ts
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
import { PaginationModule } from '@hedhog/pagination';
|
2
|
-
import { PrismaModule } from '@hedhog/prisma';
|
3
|
-
import { forwardRef, Module } from '@nestjs/common';
|
4
|
-
import { APP_GUARD } from '@nestjs/core';
|
5
|
-
import { AuthModule } from '../auth/auth.module';
|
6
|
-
import { LocaleModule } from '@hedhog/locale';
|
7
|
-
import { RoleGuard } from './guards/role.guard';
|
8
|
-
import { RoleController } from './role.controller';
|
9
|
-
import { RoleService } from './role.service';
|
10
|
-
|
11
|
-
@Module({
|
12
|
-
imports: [
|
13
|
-
forwardRef(() => AuthModule),
|
14
|
-
forwardRef(() => PrismaModule),
|
15
|
-
forwardRef(() => PaginationModule),
|
16
|
-
forwardRef(() => LocaleModule),
|
17
|
-
],
|
18
|
-
controllers: [RoleController],
|
19
|
-
providers: [
|
20
|
-
RoleService,
|
21
|
-
{
|
22
|
-
provide: APP_GUARD,
|
23
|
-
useClass: RoleGuard,
|
24
|
-
},
|
25
|
-
],
|
26
|
-
exports: [RoleService],
|
27
|
-
})
|
28
|
-
export class RoleModule {}
|
1
|
+
import { PaginationModule } from '@hedhog/pagination';
|
2
|
+
import { PrismaModule } from '@hedhog/prisma';
|
3
|
+
import { forwardRef, Module } from '@nestjs/common';
|
4
|
+
import { APP_GUARD } from '@nestjs/core';
|
5
|
+
import { AuthModule } from '../auth/auth.module';
|
6
|
+
import { LocaleModule } from '@hedhog/locale';
|
7
|
+
import { RoleGuard } from './guards/role.guard';
|
8
|
+
import { RoleController } from './role.controller';
|
9
|
+
import { RoleService } from './role.service';
|
10
|
+
|
11
|
+
@Module({
|
12
|
+
imports: [
|
13
|
+
forwardRef(() => AuthModule),
|
14
|
+
forwardRef(() => PrismaModule),
|
15
|
+
forwardRef(() => PaginationModule),
|
16
|
+
forwardRef(() => LocaleModule),
|
17
|
+
],
|
18
|
+
controllers: [RoleController],
|
19
|
+
providers: [
|
20
|
+
RoleService,
|
21
|
+
{
|
22
|
+
provide: APP_GUARD,
|
23
|
+
useClass: RoleGuard,
|
24
|
+
},
|
25
|
+
],
|
26
|
+
exports: [RoleService],
|
27
|
+
})
|
28
|
+
export class RoleModule {}
|