Skip to content

Commit 89ad6d4

Browse files
Add getUser endpoint (#10)
* worked on getUser method and user parameters --------- Co-authored-by: Kenny Jung <dukyoung01@naver.com>
1 parent 2c17a6b commit 89ad6d4

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

apps/backend/src/users/user.entity.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { IsEmail, IsUrl } from 'class-validator';
12
import { Entity, Column } from 'typeorm';
2-
import { Status, Role, Team } from './types';
3+
import { Role, Status, Team } from './types';
34

45
@Entity()
56
export class User {
@@ -19,12 +20,14 @@ export class User {
1920
lastName: string;
2021

2122
@Column()
23+
@IsEmail()
2224
email: string;
2325

2426
@Column()
2527
profilePicture: string | null;
2628

2729
@Column()
30+
@IsUrl()
2831
linkedin: string | null;
2932

3033
@Column()

apps/backend/src/users/users.controller.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ export class UsersController {
2222

2323
@UseGuards(AuthGuard('jwt'))
2424
@Get('/:userId')
25-
async getUser(@Param('userId', ParseIntPipe) userId: number): Promise<User> {
25+
getUser(@Param('userId', ParseIntPipe) userId: number) {
2626
return this.usersService.findOne(userId);
2727
}
2828

29-
@Delete('/:id')
30-
removeUser(@Param('id') id: string) {
31-
return this.usersService.remove(parseInt(id));
32-
}
33-
3429
@Patch(':userId')
3530
async updateUser(
3631
@Body() updateUserDTO: UpdateUserDTO,
3732
@Param('userId', ParseIntPipe) userId: number,
3833
): Promise<User> {
3934
return this.usersService.updateUser(updateUserDTO, userId);
4035
}
36+
37+
@Delete('/:id')
38+
removeUser(@Param('id') id: string) {
39+
return this.usersService.remove(parseInt(id));
40+
}
4141
}

apps/backend/src/users/users.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
2-
Injectable,
32
BadRequestException,
3+
Injectable,
44
UnauthorizedException,
55
NotFoundException,
66
} from '@nestjs/common';

apps/backend/src/users/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Status } from './types';
22
import { User } from './user.entity';
33

44
export const getCurrentUser = (): User => ({
5-
userId: 999,
5+
userId: 1,
66
status: Status.ADMIN,
77
firstName: 'jimmy',
88
lastName: 'jimmy2',

0 commit comments

Comments
 (0)