Skip to content

Commit 2677c07

Browse files
committed
feat: add updateProfile endpoint and service method in UserController and UserService
1 parent 71c15bd commit 2677c07

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

server/src/user/user.controller.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { GetRequestToken, validateUser } from '@server/GetRequestUser';
44
import { PageQueryDTO } from '@shared/validation/common/dto/PageQuery.dto';
55
import { GetUser } from '@shared/validation/user/dto/GetUser.dto';
66
import { UpdateUsernameDto } from '@shared/validation/user/dto/UpdateUsername.dto';
7+
import { UpdateUserProfileDto } from '@shared/validation/user/dto/UpdateUserProfile.dto';
78

89
import { UserDocument } from './entity/user.entity';
910
import { UserService } from './user.service';
@@ -47,4 +48,16 @@ export class UserController {
4748
user = validateUser(user);
4849
return await this.userService.updateUsername(user, body);
4950
}
51+
52+
@Patch('profile')
53+
@ApiTags('user')
54+
@ApiBearerAuth()
55+
@ApiOperation({ summary: 'Update the profile' })
56+
async updateProfile(
57+
@GetRequestToken() user: UserDocument | null,
58+
@Body() body: UpdateUserProfileDto,
59+
) {
60+
user = validateUser(user);
61+
return await this.userService.updateProfile(user, body);
62+
}
5063
}

server/src/user/user.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { validate } from 'class-validator';
77
import { Model } from 'mongoose';
88
import { UpdateUsernameDto } from '@shared/validation/user/dto/UpdateUsername.dto';
99
import { User, UserDocument } from './entity/user.entity';
10+
import { UpdateUserProfileDto } from '@shared/validation/user/dto/UpdateUserProfile.dto';
1011

1112
@Injectable()
1213
export class UserService {
@@ -148,4 +149,8 @@ export class UserService {
148149

149150
return await user.save();
150151
}
152+
153+
public async updateProfile(user: UserDocument, body: UpdateUserProfileDto) {
154+
throw new Error('Method not implemented.');
155+
}
151156
}

0 commit comments

Comments
 (0)