Skip to content

Commit

Permalink
chore: eslint 오류 내용 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
Muungi committed Nov 16, 2023
1 parent b298a99 commit cfa9631
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 0 additions & 2 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { typeORMConfig } from './configs/typeorm.config';
import { UsersModule } from './user/user.module';
Expand Down
4 changes: 3 additions & 1 deletion backend/src/configs/typeorm.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import { config } from 'dotenv';

if (process.env.NODE_ENV === 'dev') {config()}
if (process.env.NODE_ENV === 'dev') {
config();
}

export const typeORMConfig: TypeOrmModuleOptions = {
type: 'mysql',
Expand Down
2 changes: 1 addition & 1 deletion backend/src/exceptions/exception.fillter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class DuplicateEmailExceptionFilter implements ExceptionFilter {
message: '이메일 중복',
});
return;
}
}
if (exception instanceof ValidationException) {
response.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
statusCode: exception.getStatus(),
Expand Down
4 changes: 2 additions & 2 deletions backend/src/exceptions/validation.exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { BadRequestException, HttpStatus } from '@nestjs/common';

export class ValidationException extends BadRequestException {
constructor(message: string) {
super({ statusCode: HttpStatus.BAD_REQUEST, message});
super({ statusCode: HttpStatus.BAD_REQUEST, message });
}

getMessage() {
return this.message;
}
}
}
20 changes: 10 additions & 10 deletions backend/src/exceptions/validation.user.pipe.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { ValidationPipe } from "@nestjs/common";
import { ValidationException } from "./validation.exception";
import { ValidationPipe } from '@nestjs/common';
import { ValidationException } from './validation.exception';

export class UserValidationPipe extends ValidationPipe {
export class UserValidationPipe extends ValidationPipe {
exceptionFactory = (errors: any[]) => {
const customErrors = errors.map((error) => {
return {
property: error.property,
constraints: error.constraints,
message: 'Custom validation error message',
};
errors.map((error) => {
return {
property: error.property,
constraints: error.constraints,
message: 'Custom validation error message',
};
});
throw new ValidationException('입력 값이 유효하지 않습니다');
};
}
}
4 changes: 2 additions & 2 deletions backend/src/user/user.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Body, Controller, Post, HttpStatus, UseFilters, UsePipes, ValidationPipe } from '@nestjs/common';
import { Body, Controller, Post, HttpStatus, UseFilters, UsePipes } from '@nestjs/common';
import { UsersService } from './user.service';
import { UserDto } from './dto/user.dto';
import { DuplicateEmailExceptionFilter } from 'src/exceptions/exception.fillter';
Expand All @@ -11,7 +11,7 @@ export class UsersController {

@Post('register')
@UsePipes(new UserValidationPipe())
async registerUser(@Body() userDto: UserDto): Promise<{ statusCode: number, message: string }> {
async registerUser(@Body() userDto: UserDto): Promise<{ statusCode: number; message: string }> {
await this.userService.registerUser(userDto);
return { statusCode: HttpStatus.OK, message: '회원가입 성공' };
}
Expand Down

0 comments on commit cfa9631

Please sign in to comment.