Skip to content

Commit

Permalink
API에 들어갈 DTO 작성 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
novice0840 committed Jul 27, 2023
1 parent c5584c6 commit ac10cd8
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 15 deletions.
18 changes: 8 additions & 10 deletions backend/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import { Controller, Post, Body } from '@nestjs/common';
import { AuthService } from './auth.service';
import { CreateUserDto } from './dto/create-user.dto';
import { LoginUserDto } from './dto/login-user.dto';

@Controller('auth')
export class AuthController {
constructor(private readonly authService: AuthService) {}

@Post()
login(@Body('email') email: string, @Body('password') password: string) {
return { email, password };
@Post('/login')
login(@Body() loginUserDto: LoginUserDto) {
return loginUserDto;
}

@Post()
signup(
@Body('name') name: string,
@Body('email') email: string,
@Body('password') password: string,
) {
return { name, email, password };
@Post('/signup')
signup(@Body() createUserDto: CreateUserDto) {
return createUserDto;
}
}
12 changes: 12 additions & 0 deletions backend/src/auth/dto/create-user.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { IsString, IsEmail } from 'class-validator';

export class CreateUserDto {
@IsString()
name: string;

@IsEmail()
email: string;

@IsString()
password: string;
}
9 changes: 9 additions & 0 deletions backend/src/auth/dto/login-user.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { IsString, IsEmail } from 'class-validator';

export class LoginUserDto {
@IsEmail()
email: string;

@IsString()
password: string;
}
33 changes: 30 additions & 3 deletions backend/src/comment/comment.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
import { Controller, Get } from '@nestjs/common';
import { Controller, Get, Post, Delete } from '@nestjs/common';
import { CommentService } from './comment.service';

@Controller('comment')
export class CommentController {
constructor(private readonly commentService: CommentService) {}

@Get()
getUser(): string {
@Post()
createComment() {
return 'get user information';
}

// 특정 웹툰의 댓글을 보는 기능
@Get('webtoon/:webtoonId')
getWebtoonComments() {
return 'geting comments';
}

// 자신이 쓴 댓글 목록을 보는 기능
@Get('user/:userId')
getUserComments() {
return 'reading comments';
}

@Post('like')
clickLike() {
return 'click like';
}

@Post('dislike')
clickDislike() {
return 'click like';
}

@Delete(':commentId')
deleteComment() {
return 'delete comment';
}
}
12 changes: 12 additions & 0 deletions backend/src/user/dto/update-user.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { IsString, IsEmail } from 'class-validator';

export class UpdateUserDto {
@IsString()
name: string;

@IsEmail()
email: string;

@IsString()
password: string;
}
15 changes: 13 additions & 2 deletions backend/src/user/user.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import { Controller, Get } from '@nestjs/common';
import { Controller, Get, Put, Delete, Body } from '@nestjs/common';
import { UserService } from './user.service';
import { UpdateUserDto } from './dto/update-user.dto';

@Controller('user')
export class UserController {
constructor(private readonly userService: UserService) {}

@Get()
getUser(): string {
getUser() {
return 'get user information';
}

@Put()
updateUser(@Body() updateUserDto: UpdateUserDto) {
return updateUserDto;
}

@Delete()
deleteUser() {
return 'delete user';
}
}

0 comments on commit ac10cd8

Please sign in to comment.