speedrun-cli 2.6.1
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/CHANGELOG.md +96 -0
- package/LICENSE +21 -0
- package/README.md +620 -0
- package/bin/cli.js +224 -0
- package/index.js +12 -0
- package/package.json +74 -0
- package/src/constants.js +65 -0
- package/src/generator.js +271 -0
- package/src/index.js +13 -0
- package/src/moduleGenerator.js +586 -0
- package/src/postSetup.js +365 -0
- package/src/prompts.js +189 -0
- package/src/utils.js +112 -0
- package/templates/README.md +81 -0
- package/templates/base/eslint.config.mjs +34 -0
- package/templates/base/gitignore +78 -0
- package/templates/base/nest-cli.json +8 -0
- package/templates/base/src/common/constants/cookie.config.ts +20 -0
- package/templates/base/src/common/decorators/get-user.decorator.ts +13 -0
- package/templates/base/src/common/decorators/public.decorator.ts +4 -0
- package/templates/base/src/common/decorators/roles.decorator.ts +4 -0
- package/templates/base/src/common/dtos/pagination.dto.ts +29 -0
- package/templates/base/src/common/filters/http-exception.filter.ts +108 -0
- package/templates/base/src/common/guards/auth.guard.ts +51 -0
- package/templates/base/src/common/guards/refresh-token.guard.ts +39 -0
- package/templates/base/src/common/guards/roles.guard.ts +45 -0
- package/templates/base/src/common/interceptors/response.interceptor.ts +55 -0
- package/templates/base/src/common/interfaces/api-response.interface.ts +26 -0
- package/templates/base/src/common/middleware/correlation-id.middleware.ts +20 -0
- package/templates/base/src/common/validators/password.validator.ts +37 -0
- package/templates/base/src/config/config.module.ts +14 -0
- package/templates/base/src/config/logger.config.ts +109 -0
- package/templates/base/src/main.ts +84 -0
- package/templates/base/src/modules/auth/auth.controller.ts +133 -0
- package/templates/base/src/modules/auth/dtos/login.dto.ts +11 -0
- package/templates/base/src/modules/auth/dtos/signup.dto.ts +8 -0
- package/templates/base/src/modules/health/health.controller.ts +20 -0
- package/templates/base/src/modules/health/health.module.ts +7 -0
- package/templates/base/src/modules/users/dtos/update-profile.dto.ts +12 -0
- package/templates/base/src/modules/users/dtos/update-user.dto.ts +13 -0
- package/templates/base/src/modules/users/users.controller.ts +65 -0
- package/templates/base/test/app.e2e-spec.ts +24 -0
- package/templates/base/test/jest-e2e.json +9 -0
- package/templates/base/tsconfig.build.json +4 -0
- package/templates/base/tsconfig.json +24 -0
- package/templates/base-crud/CRUD_README.md +385 -0
- package/templates/base-crud/src/common/base/base.controller.ts +321 -0
- package/templates/base-crud/src/common/base/base.service.ts +192 -0
- package/templates/base-crud/src/common/base/index.ts +20 -0
- package/templates/base-crud/src/common/base/swagger/api-response.dto.ts +82 -0
- package/templates/base-crud/src/common/base/swagger/paginated.dto.ts +102 -0
- package/templates/base-crud/src/modules/products/dto/create-product.dto.ts +44 -0
- package/templates/base-crud/src/modules/products/dto/product.dto.ts +38 -0
- package/templates/base-crud/src/modules/products/dto/update-product.dto.ts +12 -0
- package/templates/base-crud/src/modules/products/products.controller.ts +94 -0
- package/templates/base-crud-drizzle/src/modules/products/products.controller.ts +79 -0
- package/templates/base-crud-drizzle/src/modules/products/products.module.ts +24 -0
- package/templates/base-crud-drizzle/src/modules/products/products.service.ts +140 -0
- package/templates/base-crud-drizzle/src/modules/products/schema/products.schema.ts +39 -0
- package/templates/base-crud-mongoose/src/modules/products/products.controller.ts +79 -0
- package/templates/base-crud-mongoose/src/modules/products/products.module.ts +26 -0
- package/templates/base-crud-mongoose/src/modules/products/products.service.ts +133 -0
- package/templates/base-crud-mongoose/src/modules/products/schemas/product.schema.ts +67 -0
- package/templates/base-crud-prisma/src/modules/products/products.module.ts +12 -0
- package/templates/base-crud-prisma/src/modules/products/products.service.ts +100 -0
- package/templates/base-crud-typeorm/src/modules/products/entities/product.entity.ts +58 -0
- package/templates/base-crud-typeorm/src/modules/products/products.controller.ts +79 -0
- package/templates/base-crud-typeorm/src/modules/products/products.module.ts +25 -0
- package/templates/base-crud-typeorm/src/modules/products/products.service.ts +102 -0
- package/templates/database/mongodb/.env.example +22 -0
- package/templates/database/mysql/.env.example +24 -0
- package/templates/database/mysql/drizzle.config.ts +13 -0
- package/templates/database/mysql/package.json +5 -0
- package/templates/database/mysql/prisma/schema.prisma +55 -0
- package/templates/database/mysql/src/database/drizzle.ts +13 -0
- package/templates/database/mysql/src/database/schema.ts +58 -0
- package/templates/database/postgres/.env.example +24 -0
- package/templates/database/postgres/drizzle.config.ts +13 -0
- package/templates/database/postgres/package.json +8 -0
- package/templates/database/postgres/prisma/schema.prisma +55 -0
- package/templates/database/sqlite/.env.example +24 -0
- package/templates/database/sqlite/drizzle.config.ts +13 -0
- package/templates/database/sqlite/package.json +8 -0
- package/templates/database/sqlite/prisma/schema.prisma +48 -0
- package/templates/database/sqlite/src/database/drizzle.ts +11 -0
- package/templates/database/sqlite/src/database/schema.ts +52 -0
- package/templates/orm/drizzle/drizzle.config.ts +13 -0
- package/templates/orm/drizzle/package.json +90 -0
- package/templates/orm/drizzle/src/app.module.ts +73 -0
- package/templates/orm/drizzle/src/config/env.validation.ts +55 -0
- package/templates/orm/drizzle/src/database/database.module.ts +25 -0
- package/templates/orm/drizzle/src/database/drizzle.ts +13 -0
- package/templates/orm/drizzle/src/database/schema.ts +60 -0
- package/templates/orm/drizzle/src/database/seed.ts +87 -0
- package/templates/orm/drizzle/src/modules/auth/auth.module.ts +12 -0
- package/templates/orm/drizzle/src/modules/auth/auth.service.ts +298 -0
- package/templates/orm/drizzle/src/modules/health/health.controller.ts +34 -0
- package/templates/orm/drizzle/src/modules/health/health.module.ts +7 -0
- package/templates/orm/drizzle/src/modules/users/users.module.ts +10 -0
- package/templates/orm/drizzle/src/modules/users/users.service.ts +152 -0
- package/templates/orm/mongoose/.env.example +22 -0
- package/templates/orm/mongoose/package.json +86 -0
- package/templates/orm/mongoose/src/app.module.ts +73 -0
- package/templates/orm/mongoose/src/config/env.validation.ts +55 -0
- package/templates/orm/mongoose/src/database/database.module.ts +19 -0
- package/templates/orm/mongoose/src/database/seed.ts +107 -0
- package/templates/orm/mongoose/src/modules/auth/auth.module.ts +21 -0
- package/templates/orm/mongoose/src/modules/auth/auth.service.ts +272 -0
- package/templates/orm/mongoose/src/modules/auth/dtos/login.dto.ts +10 -0
- package/templates/orm/mongoose/src/modules/auth/dtos/signup.dto.ts +8 -0
- package/templates/orm/mongoose/src/modules/health/health.controller.ts +26 -0
- package/templates/orm/mongoose/src/modules/health/health.module.ts +7 -0
- package/templates/orm/mongoose/src/modules/users/dtos/update-profile.dto.ts +24 -0
- package/templates/orm/mongoose/src/modules/users/dtos/update-user.dto.ts +13 -0
- package/templates/orm/mongoose/src/modules/users/users.module.ts +19 -0
- package/templates/orm/mongoose/src/modules/users/users.service.ts +179 -0
- package/templates/orm/mongoose/src/schemas/index.ts +2 -0
- package/templates/orm/mongoose/src/schemas/refresh-token.schema.ts +55 -0
- package/templates/orm/mongoose/src/schemas/user.schema.ts +53 -0
- package/templates/orm/prisma/package.json +102 -0
- package/templates/orm/prisma/prisma/schema.prisma +60 -0
- package/templates/orm/prisma/prisma/seed.ts +69 -0
- package/templates/orm/prisma/src/app.module.ts +55 -0
- package/templates/orm/prisma/src/config/env.validation.ts +56 -0
- package/templates/orm/prisma/src/modules/auth/auth.module.ts +17 -0
- package/templates/orm/prisma/src/modules/auth/auth.service.ts +308 -0
- package/templates/orm/prisma/src/modules/health/health.controller.ts +26 -0
- package/templates/orm/prisma/src/modules/health/health.module.ts +10 -0
- package/templates/orm/prisma/src/modules/users/users.module.ts +11 -0
- package/templates/orm/prisma/src/modules/users/users.service.ts +105 -0
- package/templates/orm/prisma/src/prisma/prisma.module.ts +9 -0
- package/templates/orm/prisma/src/prisma/prisma.service.ts +16 -0
- package/templates/orm/typeorm/package.json +100 -0
- package/templates/orm/typeorm/src/app.module.ts +55 -0
- package/templates/orm/typeorm/src/config/env.validation.ts +58 -0
- package/templates/orm/typeorm/src/database/data-source.ts +19 -0
- package/templates/orm/typeorm/src/database/database.module.ts +27 -0
- package/templates/orm/typeorm/src/database/seed.ts +76 -0
- package/templates/orm/typeorm/src/entities/index.ts +2 -0
- package/templates/orm/typeorm/src/entities/refresh-token.entity.ts +45 -0
- package/templates/orm/typeorm/src/entities/user.entity.ts +51 -0
- package/templates/orm/typeorm/src/modules/auth/auth.module.ts +19 -0
- package/templates/orm/typeorm/src/modules/auth/auth.service.ts +286 -0
- package/templates/orm/typeorm/src/modules/health/health.controller.ts +24 -0
- package/templates/orm/typeorm/src/modules/health/health.module.ts +9 -0
- package/templates/orm/typeorm/src/modules/users/users.module.ts +13 -0
- package/templates/orm/typeorm/src/modules/users/users.service.ts +108 -0
- package/templates/swagger/src/common/dtos/pagination.dto.ts +43 -0
- package/templates/swagger/src/main.ts +116 -0
- package/templates/swagger/src/modules/auth/auth.controller.ts +235 -0
- package/templates/swagger/src/modules/auth/dtos/login.dto.ts +20 -0
- package/templates/swagger/src/modules/auth/dtos/signup.dto.ts +14 -0
- package/templates/swagger/src/modules/users/dtos/update-profile.dto.ts +19 -0
- package/templates/swagger/src/modules/users/dtos/update-user.dto.ts +23 -0
- package/templates/swagger/src/modules/users/users.controller.ts +214 -0
- package/templates/swagger-mongoose/src/modules/auth/dtos/login.dto.ts +20 -0
- package/templates/swagger-mongoose/src/modules/auth/dtos/signup.dto.ts +14 -0
- package/templates/swagger-mongoose/src/modules/users/dtos/update-profile.dto.ts +40 -0
- package/templates/swagger-mongoose/src/modules/users/dtos/update-user.dto.ts +23 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Body,
|
|
3
|
+
Controller,
|
|
4
|
+
Delete,
|
|
5
|
+
Get,
|
|
6
|
+
Param,
|
|
7
|
+
Patch,
|
|
8
|
+
Query,
|
|
9
|
+
} from '@nestjs/common';
|
|
10
|
+
import {
|
|
11
|
+
ApiTags,
|
|
12
|
+
ApiOperation,
|
|
13
|
+
ApiResponse,
|
|
14
|
+
ApiBearerAuth,
|
|
15
|
+
} from '@nestjs/swagger';
|
|
16
|
+
import { UsersService } from './users.service';
|
|
17
|
+
import { GetUser } from 'src/common/decorators/get-user.decorator';
|
|
18
|
+
import { Roles } from 'src/common/decorators/roles.decorator';
|
|
19
|
+
import { UserRole } from 'src/common/guards/roles.guard';
|
|
20
|
+
import { UpdateUserDto } from './dtos/update-user.dto';
|
|
21
|
+
import { UpdateProfileDto } from './dtos/update-profile.dto';
|
|
22
|
+
import { PaginationDto } from 'src/common/dtos/pagination.dto';
|
|
23
|
+
|
|
24
|
+
@ApiBearerAuth('bearer')
|
|
25
|
+
@ApiTags('Users')
|
|
26
|
+
@Controller('users')
|
|
27
|
+
export class UsersController {
|
|
28
|
+
constructor(private readonly usersService: UsersService) {}
|
|
29
|
+
|
|
30
|
+
// profile routes
|
|
31
|
+
@ApiOperation({ summary: 'Get current user profile' })
|
|
32
|
+
@ApiResponse({
|
|
33
|
+
status: 200,
|
|
34
|
+
description: 'Returns the authenticated user profile.',
|
|
35
|
+
schema: {
|
|
36
|
+
example: {
|
|
37
|
+
statusCode: 200,
|
|
38
|
+
data: {
|
|
39
|
+
id: 'clxyz...',
|
|
40
|
+
email: 'user@example.com',
|
|
41
|
+
fullName: 'John Doe',
|
|
42
|
+
role: 'USER',
|
|
43
|
+
isActive: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
@ApiResponse({
|
|
49
|
+
status: 401,
|
|
50
|
+
description: 'Unauthorized - invalid or missing JWT token.',
|
|
51
|
+
})
|
|
52
|
+
@Get('/profile')
|
|
53
|
+
async getProfile(@GetUser('sub') userId: string) {
|
|
54
|
+
return this.usersService.getProfile(userId);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@ApiOperation({ summary: 'Update current user profile' })
|
|
58
|
+
@ApiResponse({
|
|
59
|
+
status: 200,
|
|
60
|
+
description: 'Profile updated successfully.',
|
|
61
|
+
schema: {
|
|
62
|
+
example: {
|
|
63
|
+
statusCode: 200,
|
|
64
|
+
message: 'Profile updated successfully',
|
|
65
|
+
data: {
|
|
66
|
+
id: 'clxyz...',
|
|
67
|
+
email: 'user@example.com',
|
|
68
|
+
fullName: 'Jane Doe',
|
|
69
|
+
role: 'USER',
|
|
70
|
+
isActive: true,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
@ApiResponse({
|
|
76
|
+
status: 401,
|
|
77
|
+
description: 'Unauthorized - invalid or missing JWT token.',
|
|
78
|
+
})
|
|
79
|
+
@Patch('/profile')
|
|
80
|
+
async updateProfile(
|
|
81
|
+
@GetUser('sub') userId: string,
|
|
82
|
+
@Body() updateProfileDto: UpdateProfileDto,
|
|
83
|
+
) {
|
|
84
|
+
return this.usersService.updateProfile(userId, updateProfileDto);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// admin routes
|
|
88
|
+
@ApiOperation({ summary: 'Get all users (Admin only)' })
|
|
89
|
+
@ApiResponse({
|
|
90
|
+
status: 200,
|
|
91
|
+
description: 'Returns a paginated list of all users.',
|
|
92
|
+
schema: {
|
|
93
|
+
example: {
|
|
94
|
+
statusCode: 200,
|
|
95
|
+
data: {
|
|
96
|
+
data: [
|
|
97
|
+
{
|
|
98
|
+
id: 'clxyz...',
|
|
99
|
+
email: 'user@example.com',
|
|
100
|
+
fullName: 'John Doe',
|
|
101
|
+
role: 'USER',
|
|
102
|
+
isActive: true,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
meta: {
|
|
106
|
+
total: 50,
|
|
107
|
+
page: 1,
|
|
108
|
+
limit: 10,
|
|
109
|
+
totalPages: 5,
|
|
110
|
+
hasNext: true,
|
|
111
|
+
hasPrevious: false,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
@ApiResponse({
|
|
118
|
+
status: 401,
|
|
119
|
+
description: 'Unauthorized - invalid or missing JWT token.',
|
|
120
|
+
})
|
|
121
|
+
@ApiResponse({ status: 403, description: 'Forbidden - Admin role required.' })
|
|
122
|
+
@Roles(UserRole.ADMIN)
|
|
123
|
+
@Get('/')
|
|
124
|
+
async getAllUsers(@Query() paginationDto: PaginationDto) {
|
|
125
|
+
const { page = 1, limit = 10 } = paginationDto;
|
|
126
|
+
return this.usersService.getAllUsers(page, limit);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@ApiOperation({ summary: 'Get a user by ID (Admin only)' })
|
|
130
|
+
@ApiResponse({
|
|
131
|
+
status: 200,
|
|
132
|
+
description: 'Returns the user with the specified ID.',
|
|
133
|
+
schema: {
|
|
134
|
+
example: {
|
|
135
|
+
statusCode: 200,
|
|
136
|
+
data: {
|
|
137
|
+
id: 'clxyz...',
|
|
138
|
+
email: 'user@example.com',
|
|
139
|
+
fullName: 'John Doe',
|
|
140
|
+
role: 'USER',
|
|
141
|
+
isActive: true,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
})
|
|
146
|
+
@ApiResponse({
|
|
147
|
+
status: 401,
|
|
148
|
+
description: 'Unauthorized - invalid or missing JWT token.',
|
|
149
|
+
})
|
|
150
|
+
@ApiResponse({ status: 403, description: 'Forbidden - Admin role required.' })
|
|
151
|
+
@ApiResponse({ status: 404, description: 'User not found.' })
|
|
152
|
+
@Roles(UserRole.ADMIN)
|
|
153
|
+
@Get('/:id')
|
|
154
|
+
async getUserById(@Param('id') id: string) {
|
|
155
|
+
return this.usersService.getUserById(id);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@ApiOperation({ summary: 'Update a user by ID (Admin only)' })
|
|
159
|
+
@ApiResponse({
|
|
160
|
+
status: 200,
|
|
161
|
+
description: 'User updated successfully.',
|
|
162
|
+
schema: {
|
|
163
|
+
example: {
|
|
164
|
+
statusCode: 200,
|
|
165
|
+
message: 'User updated successfully',
|
|
166
|
+
data: {
|
|
167
|
+
id: 'clxyz...',
|
|
168
|
+
email: 'user@example.com',
|
|
169
|
+
fullName: 'John Doe',
|
|
170
|
+
role: 'ADMIN',
|
|
171
|
+
isActive: true,
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
})
|
|
176
|
+
@ApiResponse({
|
|
177
|
+
status: 401,
|
|
178
|
+
description: 'Unauthorized - invalid or missing JWT token.',
|
|
179
|
+
})
|
|
180
|
+
@ApiResponse({ status: 403, description: 'Forbidden - Admin role required.' })
|
|
181
|
+
@ApiResponse({ status: 404, description: 'User not found.' })
|
|
182
|
+
@Roles(UserRole.ADMIN)
|
|
183
|
+
@Patch('/:id')
|
|
184
|
+
async updateUserById(
|
|
185
|
+
@Param('id') id: string,
|
|
186
|
+
@Body() updateUserDto: UpdateUserDto,
|
|
187
|
+
) {
|
|
188
|
+
return this.usersService.updateUserById(id, updateUserDto);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
//this soft deletes a user by setting isActive to false
|
|
192
|
+
@ApiOperation({ summary: 'Soft delete a user by ID (Admin only)' })
|
|
193
|
+
@ApiResponse({
|
|
194
|
+
status: 200,
|
|
195
|
+
description: 'User deactivated successfully.',
|
|
196
|
+
schema: {
|
|
197
|
+
example: {
|
|
198
|
+
statusCode: 200,
|
|
199
|
+
message: 'User deactivated successfully',
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
})
|
|
203
|
+
@ApiResponse({
|
|
204
|
+
status: 401,
|
|
205
|
+
description: 'Unauthorized - invalid or missing JWT token.',
|
|
206
|
+
})
|
|
207
|
+
@ApiResponse({ status: 403, description: 'Forbidden - Admin role required.' })
|
|
208
|
+
@ApiResponse({ status: 404, description: 'User not found.' })
|
|
209
|
+
@Roles(UserRole.ADMIN)
|
|
210
|
+
@Delete('/:id')
|
|
211
|
+
async deleteUserById(@Param('id') id: string) {
|
|
212
|
+
return this.usersService.deleteUserById(id);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import { IsEmail, IsString, MinLength } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
export class LoginDto {
|
|
5
|
+
@ApiProperty({
|
|
6
|
+
description: 'User email address',
|
|
7
|
+
example: 'user@example.com',
|
|
8
|
+
})
|
|
9
|
+
@IsEmail()
|
|
10
|
+
email: string;
|
|
11
|
+
|
|
12
|
+
@ApiProperty({
|
|
13
|
+
description: 'User password (minimum 6 characters)',
|
|
14
|
+
example: 'MyP@ssw0rd',
|
|
15
|
+
minLength: 6,
|
|
16
|
+
})
|
|
17
|
+
@IsString()
|
|
18
|
+
@MinLength(6)
|
|
19
|
+
password: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import { IsString, MinLength } from 'class-validator';
|
|
3
|
+
import { LoginDto } from './login.dto';
|
|
4
|
+
|
|
5
|
+
export class SignupDto extends LoginDto {
|
|
6
|
+
@ApiProperty({
|
|
7
|
+
description: 'User full name',
|
|
8
|
+
example: 'John Doe',
|
|
9
|
+
minLength: 2,
|
|
10
|
+
})
|
|
11
|
+
@IsString()
|
|
12
|
+
@MinLength(2)
|
|
13
|
+
fullName: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import {
|
|
3
|
+
IsEmail,
|
|
4
|
+
IsOptional,
|
|
5
|
+
IsString,
|
|
6
|
+
MaxLength,
|
|
7
|
+
MinLength,
|
|
8
|
+
} from 'class-validator';
|
|
9
|
+
|
|
10
|
+
export class UpdateProfileDto {
|
|
11
|
+
@ApiPropertyOptional({
|
|
12
|
+
description: 'User full name',
|
|
13
|
+
example: 'Jane Doe',
|
|
14
|
+
minLength: 2,
|
|
15
|
+
maxLength: 100,
|
|
16
|
+
})
|
|
17
|
+
@IsOptional()
|
|
18
|
+
@IsString()
|
|
19
|
+
@MinLength(2)
|
|
20
|
+
@MaxLength(100)
|
|
21
|
+
fullName?: string;
|
|
22
|
+
|
|
23
|
+
@ApiPropertyOptional({
|
|
24
|
+
description: 'User email address',
|
|
25
|
+
example: 'newemail@example.com',
|
|
26
|
+
})
|
|
27
|
+
@IsOptional()
|
|
28
|
+
@IsEmail()
|
|
29
|
+
email?: string;
|
|
30
|
+
|
|
31
|
+
@ApiPropertyOptional({
|
|
32
|
+
description: 'New password (minimum 6 characters)',
|
|
33
|
+
example: 'NewP@ssw0rd',
|
|
34
|
+
minLength: 6,
|
|
35
|
+
})
|
|
36
|
+
@IsOptional()
|
|
37
|
+
@IsString()
|
|
38
|
+
@MinLength(6)
|
|
39
|
+
password?: string;
|
|
40
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import { IsBoolean, IsEnum, IsOptional } from 'class-validator';
|
|
3
|
+
import { UpdateProfileDto } from './update-profile.dto';
|
|
4
|
+
import { UserRole } from '../../../schemas/user.schema';
|
|
5
|
+
|
|
6
|
+
export class UpdateUserDto extends UpdateProfileDto {
|
|
7
|
+
@ApiPropertyOptional({
|
|
8
|
+
description: 'User role',
|
|
9
|
+
enum: UserRole,
|
|
10
|
+
example: 'ADMIN',
|
|
11
|
+
})
|
|
12
|
+
@IsOptional()
|
|
13
|
+
@IsEnum(UserRole, { message: 'Role must be a valid UserRole' })
|
|
14
|
+
role?: UserRole;
|
|
15
|
+
|
|
16
|
+
@ApiPropertyOptional({
|
|
17
|
+
description: 'Whether the user account is active',
|
|
18
|
+
example: true,
|
|
19
|
+
})
|
|
20
|
+
@IsOptional()
|
|
21
|
+
@IsBoolean()
|
|
22
|
+
isActive?: boolean;
|
|
23
|
+
}
|