@hedhog/admin 0.11.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
package/src/role/role.service.ts
CHANGED
@@ -1,289 +1,289 @@
|
|
1
|
-
import { PaginationDTO, PaginationService } from '@hedhog/pagination';
|
2
|
-
import { PrismaService } from '@hedhog/prisma';
|
3
|
-
import { getWithLocale } from '@hedhog/utils';
|
4
|
-
import {
|
5
|
-
BadRequestException,
|
6
|
-
Inject,
|
7
|
-
Injectable,
|
8
|
-
forwardRef,
|
9
|
-
} from '@nestjs/common';
|
10
|
-
import { DeleteDTO } from '../dto/delete.dto';
|
11
|
-
import { UpdateIdsDTO } from '../dto/update-ids.dto';
|
12
|
-
import { LocaleService } from '@hedhog/locale';
|
13
|
-
import { CreateDTO } from './dto/create.dto';
|
14
|
-
import { UpdateDTO } from './dto/update.dto';
|
15
|
-
|
16
|
-
@Injectable()
|
17
|
-
export class RoleService {
|
18
|
-
constructor(
|
19
|
-
@Inject(forwardRef(() => PrismaService))
|
20
|
-
private readonly prismaService: PrismaService,
|
21
|
-
@Inject(forwardRef(() => PaginationService))
|
22
|
-
private readonly paginationService: PaginationService,
|
23
|
-
@Inject(forwardRef(() => LocaleService))
|
24
|
-
private readonly localeService: LocaleService,
|
25
|
-
) {}
|
26
|
-
|
27
|
-
async updateUsers(roleId: number, { ids }: UpdateIdsDTO) {
|
28
|
-
await this.prismaService.role_user.deleteMany({
|
29
|
-
where: {
|
30
|
-
role_id: roleId,
|
31
|
-
},
|
32
|
-
});
|
33
|
-
|
34
|
-
return this.prismaService.role_user.createMany({
|
35
|
-
data: ids.map((userId) => ({
|
36
|
-
role_id: roleId,
|
37
|
-
user_id: userId,
|
38
|
-
})),
|
39
|
-
skipDuplicates: true,
|
40
|
-
});
|
41
|
-
}
|
42
|
-
|
43
|
-
async updateScreens(roleId: number, data: UpdateIdsDTO) {
|
44
|
-
await this.prismaService.role_screen.deleteMany({
|
45
|
-
where: {
|
46
|
-
role_id: roleId,
|
47
|
-
},
|
48
|
-
});
|
49
|
-
|
50
|
-
return this.prismaService.role_screen.createMany({
|
51
|
-
data: data.ids.map((screenId) => ({
|
52
|
-
role_id: roleId,
|
53
|
-
screen_id: screenId,
|
54
|
-
})),
|
55
|
-
skipDuplicates: true,
|
56
|
-
});
|
57
|
-
}
|
58
|
-
|
59
|
-
async updateRoutes(roleId: number, data: UpdateIdsDTO) {
|
60
|
-
await this.prismaService.role_route.deleteMany({
|
61
|
-
where: {
|
62
|
-
role_id: roleId,
|
63
|
-
},
|
64
|
-
});
|
65
|
-
|
66
|
-
return this.prismaService.role_route.createMany({
|
67
|
-
data: data.ids.map((routeId) => ({
|
68
|
-
role_id: roleId,
|
69
|
-
route_id: routeId,
|
70
|
-
})),
|
71
|
-
skipDuplicates: true,
|
72
|
-
});
|
73
|
-
}
|
74
|
-
|
75
|
-
async updateMenus(roleId: number, data: UpdateIdsDTO) {
|
76
|
-
await this.prismaService.role_menu.deleteMany({
|
77
|
-
where: {
|
78
|
-
role_id: roleId,
|
79
|
-
},
|
80
|
-
});
|
81
|
-
|
82
|
-
return this.prismaService.role_menu.createMany({
|
83
|
-
data: data.ids.map((menuId) => ({
|
84
|
-
role_id: roleId,
|
85
|
-
menu_id: menuId,
|
86
|
-
})),
|
87
|
-
skipDuplicates: true,
|
88
|
-
});
|
89
|
-
}
|
90
|
-
|
91
|
-
async listUsers(roleId: number, paginationParams: PaginationDTO) {
|
92
|
-
return this.paginationService.paginate(
|
93
|
-
this.prismaService.user,
|
94
|
-
paginationParams,
|
95
|
-
{
|
96
|
-
include: {
|
97
|
-
role_user: {
|
98
|
-
where: {
|
99
|
-
role_id: roleId,
|
100
|
-
},
|
101
|
-
select: {
|
102
|
-
user_id: true,
|
103
|
-
role_id: true,
|
104
|
-
},
|
105
|
-
},
|
106
|
-
},
|
107
|
-
},
|
108
|
-
);
|
109
|
-
}
|
110
|
-
|
111
|
-
async listMenus(
|
112
|
-
locale: string,
|
113
|
-
roleId: number,
|
114
|
-
paginationParams: PaginationDTO,
|
115
|
-
) {
|
116
|
-
return this.paginationService.paginate(
|
117
|
-
this.prismaService.menu,
|
118
|
-
paginationParams,
|
119
|
-
{
|
120
|
-
include: {
|
121
|
-
menu_locale: {
|
122
|
-
where: {
|
123
|
-
locale: {
|
124
|
-
code: locale,
|
125
|
-
},
|
126
|
-
},
|
127
|
-
select: {
|
128
|
-
name: true,
|
129
|
-
},
|
130
|
-
},
|
131
|
-
role_menu: {
|
132
|
-
where: {
|
133
|
-
role_id: roleId,
|
134
|
-
},
|
135
|
-
select: {
|
136
|
-
menu_id: true,
|
137
|
-
role_id: true,
|
138
|
-
},
|
139
|
-
},
|
140
|
-
},
|
141
|
-
},
|
142
|
-
'menu_locale',
|
143
|
-
);
|
144
|
-
}
|
145
|
-
|
146
|
-
async listRoutes(roleId: number, paginationParams: PaginationDTO) {
|
147
|
-
return this.paginationService.paginate(
|
148
|
-
this.prismaService.route,
|
149
|
-
paginationParams,
|
150
|
-
{
|
151
|
-
include: {
|
152
|
-
role_route: {
|
153
|
-
where: {
|
154
|
-
role_id: roleId,
|
155
|
-
},
|
156
|
-
select: {
|
157
|
-
route_id: true,
|
158
|
-
role_id: true,
|
159
|
-
},
|
160
|
-
},
|
161
|
-
},
|
162
|
-
},
|
163
|
-
);
|
164
|
-
}
|
165
|
-
|
166
|
-
async listScreens(
|
167
|
-
locale: string,
|
168
|
-
roleId: number,
|
169
|
-
paginationParams: PaginationDTO,
|
170
|
-
) {
|
171
|
-
return this.paginationService.paginate(
|
172
|
-
this.prismaService.screen,
|
173
|
-
paginationParams,
|
174
|
-
{
|
175
|
-
include: {
|
176
|
-
screen_locale: {
|
177
|
-
where: {
|
178
|
-
locale: {
|
179
|
-
code: locale,
|
180
|
-
},
|
181
|
-
},
|
182
|
-
select: {
|
183
|
-
name: true,
|
184
|
-
},
|
185
|
-
},
|
186
|
-
role_screen: {
|
187
|
-
where: {
|
188
|
-
role_id: roleId,
|
189
|
-
},
|
190
|
-
select: {
|
191
|
-
screen_id: true,
|
192
|
-
role_id: true,
|
193
|
-
},
|
194
|
-
},
|
195
|
-
},
|
196
|
-
},
|
197
|
-
'screen_locale',
|
198
|
-
);
|
199
|
-
}
|
200
|
-
|
201
|
-
async list(locale: string, paginationParams: PaginationDTO) {
|
202
|
-
const fields = [];
|
203
|
-
|
204
|
-
const OR: any[] = this.prismaService.createInsensitiveSearch(
|
205
|
-
fields,
|
206
|
-
paginationParams,
|
207
|
-
);
|
208
|
-
|
209
|
-
return this.paginationService.paginate(
|
210
|
-
this.prismaService.role,
|
211
|
-
paginationParams,
|
212
|
-
{
|
213
|
-
where: {
|
214
|
-
OR,
|
215
|
-
},
|
216
|
-
include: {
|
217
|
-
role_locale: {
|
218
|
-
where: {
|
219
|
-
locale: {
|
220
|
-
code: locale,
|
221
|
-
},
|
222
|
-
},
|
223
|
-
select: {
|
224
|
-
name: true,
|
225
|
-
description: true,
|
226
|
-
},
|
227
|
-
},
|
228
|
-
},
|
229
|
-
},
|
230
|
-
'role_locale',
|
231
|
-
);
|
232
|
-
}
|
233
|
-
|
234
|
-
async get(locale: string, roleId: number) {
|
235
|
-
return getWithLocale(
|
236
|
-
locale,
|
237
|
-
'role_locale',
|
238
|
-
await this.prismaService.role.findUnique({
|
239
|
-
where: { id: roleId },
|
240
|
-
include: {
|
241
|
-
role_locale: {
|
242
|
-
where: {
|
243
|
-
locale: {
|
244
|
-
enabled: true,
|
245
|
-
},
|
246
|
-
},
|
247
|
-
select: {
|
248
|
-
name: true,
|
249
|
-
description: true,
|
250
|
-
locale: {
|
251
|
-
select: {
|
252
|
-
code: true,
|
253
|
-
},
|
254
|
-
},
|
255
|
-
},
|
256
|
-
},
|
257
|
-
},
|
258
|
-
}),
|
259
|
-
);
|
260
|
-
}
|
261
|
-
|
262
|
-
async create({ slug }: CreateDTO) {
|
263
|
-
return this.localeService.createModelWithLocale('role', 'role_id', {
|
264
|
-
slug,
|
265
|
-
});
|
266
|
-
}
|
267
|
-
|
268
|
-
async update({ id, data: { slug } }: { id: number; data: UpdateDTO }) {
|
269
|
-
return this.localeService.updateModelWithLocale('role', 'role_id', id, {
|
270
|
-
slug,
|
271
|
-
});
|
272
|
-
}
|
273
|
-
|
274
|
-
async delete({ ids }: DeleteDTO) {
|
275
|
-
if (ids == undefined || ids == null) {
|
276
|
-
throw new BadRequestException(
|
277
|
-
`You must select at least one permission to delete.`,
|
278
|
-
);
|
279
|
-
}
|
280
|
-
|
281
|
-
return this.prismaService.role.deleteMany({
|
282
|
-
where: {
|
283
|
-
id: {
|
284
|
-
in: ids,
|
285
|
-
},
|
286
|
-
},
|
287
|
-
});
|
288
|
-
}
|
289
|
-
}
|
1
|
+
import { PaginationDTO, PaginationService } from '@hedhog/pagination';
|
2
|
+
import { PrismaService } from '@hedhog/prisma';
|
3
|
+
import { getWithLocale } from '@hedhog/utils';
|
4
|
+
import {
|
5
|
+
BadRequestException,
|
6
|
+
Inject,
|
7
|
+
Injectable,
|
8
|
+
forwardRef,
|
9
|
+
} from '@nestjs/common';
|
10
|
+
import { DeleteDTO } from '../dto/delete.dto';
|
11
|
+
import { UpdateIdsDTO } from '../dto/update-ids.dto';
|
12
|
+
import { LocaleService } from '@hedhog/locale';
|
13
|
+
import { CreateDTO } from './dto/create.dto';
|
14
|
+
import { UpdateDTO } from './dto/update.dto';
|
15
|
+
|
16
|
+
@Injectable()
|
17
|
+
export class RoleService {
|
18
|
+
constructor(
|
19
|
+
@Inject(forwardRef(() => PrismaService))
|
20
|
+
private readonly prismaService: PrismaService,
|
21
|
+
@Inject(forwardRef(() => PaginationService))
|
22
|
+
private readonly paginationService: PaginationService,
|
23
|
+
@Inject(forwardRef(() => LocaleService))
|
24
|
+
private readonly localeService: LocaleService,
|
25
|
+
) {}
|
26
|
+
|
27
|
+
async updateUsers(roleId: number, { ids }: UpdateIdsDTO) {
|
28
|
+
await this.prismaService.role_user.deleteMany({
|
29
|
+
where: {
|
30
|
+
role_id: roleId,
|
31
|
+
},
|
32
|
+
});
|
33
|
+
|
34
|
+
return this.prismaService.role_user.createMany({
|
35
|
+
data: ids.map((userId) => ({
|
36
|
+
role_id: roleId,
|
37
|
+
user_id: userId,
|
38
|
+
})),
|
39
|
+
skipDuplicates: true,
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
43
|
+
async updateScreens(roleId: number, data: UpdateIdsDTO) {
|
44
|
+
await this.prismaService.role_screen.deleteMany({
|
45
|
+
where: {
|
46
|
+
role_id: roleId,
|
47
|
+
},
|
48
|
+
});
|
49
|
+
|
50
|
+
return this.prismaService.role_screen.createMany({
|
51
|
+
data: data.ids.map((screenId) => ({
|
52
|
+
role_id: roleId,
|
53
|
+
screen_id: screenId,
|
54
|
+
})),
|
55
|
+
skipDuplicates: true,
|
56
|
+
});
|
57
|
+
}
|
58
|
+
|
59
|
+
async updateRoutes(roleId: number, data: UpdateIdsDTO) {
|
60
|
+
await this.prismaService.role_route.deleteMany({
|
61
|
+
where: {
|
62
|
+
role_id: roleId,
|
63
|
+
},
|
64
|
+
});
|
65
|
+
|
66
|
+
return this.prismaService.role_route.createMany({
|
67
|
+
data: data.ids.map((routeId) => ({
|
68
|
+
role_id: roleId,
|
69
|
+
route_id: routeId,
|
70
|
+
})),
|
71
|
+
skipDuplicates: true,
|
72
|
+
});
|
73
|
+
}
|
74
|
+
|
75
|
+
async updateMenus(roleId: number, data: UpdateIdsDTO) {
|
76
|
+
await this.prismaService.role_menu.deleteMany({
|
77
|
+
where: {
|
78
|
+
role_id: roleId,
|
79
|
+
},
|
80
|
+
});
|
81
|
+
|
82
|
+
return this.prismaService.role_menu.createMany({
|
83
|
+
data: data.ids.map((menuId) => ({
|
84
|
+
role_id: roleId,
|
85
|
+
menu_id: menuId,
|
86
|
+
})),
|
87
|
+
skipDuplicates: true,
|
88
|
+
});
|
89
|
+
}
|
90
|
+
|
91
|
+
async listUsers(roleId: number, paginationParams: PaginationDTO) {
|
92
|
+
return this.paginationService.paginate(
|
93
|
+
this.prismaService.user,
|
94
|
+
paginationParams,
|
95
|
+
{
|
96
|
+
include: {
|
97
|
+
role_user: {
|
98
|
+
where: {
|
99
|
+
role_id: roleId,
|
100
|
+
},
|
101
|
+
select: {
|
102
|
+
user_id: true,
|
103
|
+
role_id: true,
|
104
|
+
},
|
105
|
+
},
|
106
|
+
},
|
107
|
+
},
|
108
|
+
);
|
109
|
+
}
|
110
|
+
|
111
|
+
async listMenus(
|
112
|
+
locale: string,
|
113
|
+
roleId: number,
|
114
|
+
paginationParams: PaginationDTO,
|
115
|
+
) {
|
116
|
+
return this.paginationService.paginate(
|
117
|
+
this.prismaService.menu,
|
118
|
+
paginationParams,
|
119
|
+
{
|
120
|
+
include: {
|
121
|
+
menu_locale: {
|
122
|
+
where: {
|
123
|
+
locale: {
|
124
|
+
code: locale,
|
125
|
+
},
|
126
|
+
},
|
127
|
+
select: {
|
128
|
+
name: true,
|
129
|
+
},
|
130
|
+
},
|
131
|
+
role_menu: {
|
132
|
+
where: {
|
133
|
+
role_id: roleId,
|
134
|
+
},
|
135
|
+
select: {
|
136
|
+
menu_id: true,
|
137
|
+
role_id: true,
|
138
|
+
},
|
139
|
+
},
|
140
|
+
},
|
141
|
+
},
|
142
|
+
'menu_locale',
|
143
|
+
);
|
144
|
+
}
|
145
|
+
|
146
|
+
async listRoutes(roleId: number, paginationParams: PaginationDTO) {
|
147
|
+
return this.paginationService.paginate(
|
148
|
+
this.prismaService.route,
|
149
|
+
paginationParams,
|
150
|
+
{
|
151
|
+
include: {
|
152
|
+
role_route: {
|
153
|
+
where: {
|
154
|
+
role_id: roleId,
|
155
|
+
},
|
156
|
+
select: {
|
157
|
+
route_id: true,
|
158
|
+
role_id: true,
|
159
|
+
},
|
160
|
+
},
|
161
|
+
},
|
162
|
+
},
|
163
|
+
);
|
164
|
+
}
|
165
|
+
|
166
|
+
async listScreens(
|
167
|
+
locale: string,
|
168
|
+
roleId: number,
|
169
|
+
paginationParams: PaginationDTO,
|
170
|
+
) {
|
171
|
+
return this.paginationService.paginate(
|
172
|
+
this.prismaService.screen,
|
173
|
+
paginationParams,
|
174
|
+
{
|
175
|
+
include: {
|
176
|
+
screen_locale: {
|
177
|
+
where: {
|
178
|
+
locale: {
|
179
|
+
code: locale,
|
180
|
+
},
|
181
|
+
},
|
182
|
+
select: {
|
183
|
+
name: true,
|
184
|
+
},
|
185
|
+
},
|
186
|
+
role_screen: {
|
187
|
+
where: {
|
188
|
+
role_id: roleId,
|
189
|
+
},
|
190
|
+
select: {
|
191
|
+
screen_id: true,
|
192
|
+
role_id: true,
|
193
|
+
},
|
194
|
+
},
|
195
|
+
},
|
196
|
+
},
|
197
|
+
'screen_locale',
|
198
|
+
);
|
199
|
+
}
|
200
|
+
|
201
|
+
async list(locale: string, paginationParams: PaginationDTO) {
|
202
|
+
const fields = [];
|
203
|
+
|
204
|
+
const OR: any[] = this.prismaService.createInsensitiveSearch(
|
205
|
+
fields,
|
206
|
+
paginationParams,
|
207
|
+
);
|
208
|
+
|
209
|
+
return this.paginationService.paginate(
|
210
|
+
this.prismaService.role,
|
211
|
+
paginationParams,
|
212
|
+
{
|
213
|
+
where: {
|
214
|
+
OR,
|
215
|
+
},
|
216
|
+
include: {
|
217
|
+
role_locale: {
|
218
|
+
where: {
|
219
|
+
locale: {
|
220
|
+
code: locale,
|
221
|
+
},
|
222
|
+
},
|
223
|
+
select: {
|
224
|
+
name: true,
|
225
|
+
description: true,
|
226
|
+
},
|
227
|
+
},
|
228
|
+
},
|
229
|
+
},
|
230
|
+
'role_locale',
|
231
|
+
);
|
232
|
+
}
|
233
|
+
|
234
|
+
async get(locale: string, roleId: number) {
|
235
|
+
return getWithLocale(
|
236
|
+
locale,
|
237
|
+
'role_locale',
|
238
|
+
await this.prismaService.role.findUnique({
|
239
|
+
where: { id: roleId },
|
240
|
+
include: {
|
241
|
+
role_locale: {
|
242
|
+
where: {
|
243
|
+
locale: {
|
244
|
+
enabled: true,
|
245
|
+
},
|
246
|
+
},
|
247
|
+
select: {
|
248
|
+
name: true,
|
249
|
+
description: true,
|
250
|
+
locale: {
|
251
|
+
select: {
|
252
|
+
code: true,
|
253
|
+
},
|
254
|
+
},
|
255
|
+
},
|
256
|
+
},
|
257
|
+
},
|
258
|
+
}),
|
259
|
+
);
|
260
|
+
}
|
261
|
+
|
262
|
+
async create({ slug }: CreateDTO) {
|
263
|
+
return this.localeService.createModelWithLocale('role', 'role_id', {
|
264
|
+
slug,
|
265
|
+
});
|
266
|
+
}
|
267
|
+
|
268
|
+
async update({ id, data: { slug } }: { id: number; data: UpdateDTO }) {
|
269
|
+
return this.localeService.updateModelWithLocale('role', 'role_id', id, {
|
270
|
+
slug,
|
271
|
+
});
|
272
|
+
}
|
273
|
+
|
274
|
+
async delete({ ids }: DeleteDTO) {
|
275
|
+
if (ids == undefined || ids == null) {
|
276
|
+
throw new BadRequestException(
|
277
|
+
`You must select at least one permission to delete.`,
|
278
|
+
);
|
279
|
+
}
|
280
|
+
|
281
|
+
return this.prismaService.role.deleteMany({
|
282
|
+
where: {
|
283
|
+
id: {
|
284
|
+
in: ids,
|
285
|
+
},
|
286
|
+
},
|
287
|
+
});
|
288
|
+
}
|
289
|
+
}
|
@@ -1,13 +1,13 @@
|
|
1
|
-
import { IsIn, IsString } from 'class-validator';
|
2
|
-
import { HttpMethod } from '../../types/http-method';
|
3
|
-
|
4
|
-
export class CreateDTO {
|
5
|
-
@IsString({ message: 'The url must be a valid string.' })
|
6
|
-
url: string;
|
7
|
-
|
8
|
-
@IsString({ message: 'The method must be a string.' })
|
9
|
-
@IsIn(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD'], {
|
10
|
-
message: 'The method must be a valid HTTP method.',
|
11
|
-
})
|
12
|
-
method: HttpMethod;
|
13
|
-
}
|
1
|
+
import { IsIn, IsString } from 'class-validator';
|
2
|
+
import { HttpMethod } from '../../types/http-method';
|
3
|
+
|
4
|
+
export class CreateDTO {
|
5
|
+
@IsString({ message: 'The url must be a valid string.' })
|
6
|
+
url: string;
|
7
|
+
|
8
|
+
@IsString({ message: 'The method must be a string.' })
|
9
|
+
@IsIn(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD'], {
|
10
|
+
message: 'The method must be a valid HTTP method.',
|
11
|
+
})
|
12
|
+
method: HttpMethod;
|
13
|
+
}
|
@@ -1,15 +1,15 @@
|
|
1
|
-
import { IsIn, IsOptional, IsString } from 'class-validator';
|
2
|
-
import { HttpMethod } from '../../types/http-method';
|
3
|
-
|
4
|
-
export class UpdateDTO {
|
5
|
-
@IsString({ message: 'The url must be a valid string.' })
|
6
|
-
@IsOptional()
|
7
|
-
url?: string;
|
8
|
-
|
9
|
-
@IsString({ message: 'The method must be a string.' })
|
10
|
-
@IsOptional()
|
11
|
-
@IsIn(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD'], {
|
12
|
-
message: 'The method must be a valid HTTP method.',
|
13
|
-
})
|
14
|
-
method?: HttpMethod;
|
15
|
-
}
|
1
|
+
import { IsIn, IsOptional, IsString } from 'class-validator';
|
2
|
+
import { HttpMethod } from '../../types/http-method';
|
3
|
+
|
4
|
+
export class UpdateDTO {
|
5
|
+
@IsString({ message: 'The url must be a valid string.' })
|
6
|
+
@IsOptional()
|
7
|
+
url?: string;
|
8
|
+
|
9
|
+
@IsString({ message: 'The method must be a string.' })
|
10
|
+
@IsOptional()
|
11
|
+
@IsIn(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD'], {
|
12
|
+
message: 'The method must be a valid HTTP method.',
|
13
|
+
})
|
14
|
+
method?: HttpMethod;
|
15
|
+
}
|