Skip to content

Commit 67e948d

Browse files
authored
Merge pull request #3 from topcoder-platform/fix/member-role-validation
Fix member role validation, remove credentials from .env.sample
2 parents 9853161 + 95e769b commit 67e948d

File tree

3 files changed

+19
-27
lines changed

3 files changed

+19
-27
lines changed

.env.sample

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ AUTH0_AUDIENCE="http://localhost:4000"
1414
AUTH0_CLIENT_ID="abc123"
1515
AUTH0_CLIENT_SECRET="secret"
1616

17-
M2M_AUTH_URL="https://topcoder-dev.auth0.com/oauth/token"
18-
M2M_AUTH_CLIENT_ID="jGIf2pd3f44B1jqvOai30BIKTZanYBfU"
19-
M2M_AUTH_CLIENT_SECRET="ldzqVaVEbqhwjM5KtZ79sG8djZpAVK8Z7qieVcC3vRjI4NirgcinKSBpPwk6mYYP"
20-
M2M_AUTH_DOMAIN="topcoder-dev.auth0.com"
21-
M2M_AUTH_AUDIENCE="https://m2m.topcoder-dev.com/"
22-
M2M_AUTH_PROXY_SEREVR_URL="https://auth0proxy.topcoder-dev.com/token"
17+
M2M_AUTH_URL="Your-auth-url"
18+
M2M_AUTH_CLIENT_ID="Your-cient-id"
19+
M2M_AUTH_CLIENT_SECRET="Your-client-secret"
20+
M2M_AUTH_DOMAIN="Your-auth-domain"
21+
M2M_AUTH_AUDIENCE="Your-auth-audience"
22+
M2M_AUTH_PROXY_SEREVR_URL="Your-server-url"
2323

2424
BUSAPI_URL="http://localhost:4000/eventBus"
2525

src/api/projectMember/project-member.dto.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
22
import {
3-
IsEnum,
43
IsIn,
54
IsNotEmpty,
65
IsNumber,
@@ -26,17 +25,8 @@ const allowedUpdateRoles = [
2625
PROJECT_MEMBER_ROLE.PROJECT_MANAGER,
2726
];
2827

29-
enum ProjectMemberRole {
30-
MANAGER = 'manager',
31-
OBSERVER = 'observer',
32-
CUSTOMER = 'customer',
33-
COPILOT = 'copilot',
34-
ACCOUNT_MANAGER = 'account_manager',
35-
PROGRAM_MANAGER = 'program_manager',
36-
ACCOUNT_EXECUTIVE = 'account_executive',
37-
SOLUTION_ARCHITECT = 'solution_architect',
38-
PROJECT_MANAGER = 'project_manager',
39-
}
28+
// Use PROJECT_MEMBER_ROLE values directly instead of duplicating enum
29+
const ProjectMemberRoleValues = Object.values(PROJECT_MEMBER_ROLE);
4030

4131
export class CreateProjectMemberDto {
4232
@ApiPropertyOptional({
@@ -51,11 +41,12 @@ export class CreateProjectMemberDto {
5141

5242
@ApiProperty({
5343
name: 'role',
54-
enum: ProjectMemberRole,
44+
enum: ProjectMemberRoleValues,
5545
})
56-
@IsEnum(ProjectMemberRole)
46+
@IsString()
47+
@IsIn(ProjectMemberRoleValues)
5748
@IsOptional()
58-
role?: ProjectMemberRole;
49+
role?: string;
5950
}
6051

6152
export class UpdateProjectMemberDto {
@@ -200,11 +191,12 @@ export class ProjectMemberResponseDto {
200191
export class QueryProjectMemberDto {
201192
@ApiProperty({
202193
description: 'project member role',
203-
enum: ProjectMemberRole,
194+
enum: ProjectMemberRoleValues,
204195
})
205-
@IsEnum(ProjectMemberRole)
196+
@IsString()
197+
@IsIn(ProjectMemberRoleValues)
206198
@IsOptional()
207-
role?: ProjectMemberRole;
199+
role?: string;
208200

209201
@ApiProperty({
210202
name: 'fields',

src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ async function bootstrap() {
3939
// Add swagger docs module
4040
const config = new DocumentBuilder()
4141
.setTitle('Projects API')
42-
.setDescription('TopCoder Projects API v5 Document')
43-
.setVersion('v5')
42+
.setDescription('TopCoder Projects API v6 Document')
43+
.setVersion('v6')
4444
.addBearerAuth({
4545
type: 'http',
4646
scheme: 'bearer',
@@ -51,7 +51,7 @@ async function bootstrap() {
5151
})
5252
.build();
5353
const document = SwaggerModule.createDocument(app, config);
54-
SwaggerModule.setup('/api-docs', app, document);
54+
SwaggerModule.setup(`${AppConfig.prefix}/projects/api-docs`, app, document);
5555

5656
await app.listen(AppConfig.port);
5757
}

0 commit comments

Comments
 (0)