Skip to content

Commit

Permalink
[v1.0.7] 프로덕션 대비 ,인증번호 응답값, 로그 주석처리
Browse files Browse the repository at this point in the history
🔨 fix : [v1.0.7] 프로덕션 대비 ,인증번호 응답값, 로그 주석처리
  • Loading branch information
ImNM authored Aug 14, 2022
2 parents 80232b2 + 47ad02e commit 4deb6d5
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 59 deletions.
20 changes: 2 additions & 18 deletions src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
import {
BadRequestException,
Body,
Controller,
Get,
HttpStatus,
InternalServerErrorException,
Post,
UseGuards
} from '@nestjs/common';
import { Body, Controller, HttpStatus, Post, UseGuards } from '@nestjs/common';
import {
ApiBearerAuth,
ApiBody,
ApiExtraModels,
ApiOperation,
ApiPropertyOptions,
ApiResponse,
ApiTags,
getSchemaPath,
refs
ApiTags
} from '@nestjs/swagger';
import { RegisterUser } from 'src/common/decorators/registerUser.decorator';
import { makeInstanceByApiProperty } from 'src/common/utils/makeInstanceByApiProperty';
import { User } from 'src/database/entities/user.entity';
import { RegisterJwtPayload } from './auth.interface';
import { AuthService } from './auth.service';
import { RequestAdminLoginDto } from './dtos/AdminLogin.request.dto';
Expand All @@ -38,7 +23,6 @@ import { ThrottlerBehindProxyGuard } from './guards/TrottlerBehindProxy.guard';
import { FirstReigsterDto } from './dtos/FirstRegister.response.dto copy';
import { LoginResponseDto } from './dtos/Login.response.dto';
import { ErrorResponse } from 'src/common/decorators/ErrorResponse.decorator';
import { ThrottlerException } from '@nestjs/throttler';
import { SuccessResponse } from 'src/common/decorators/SuccessResponse.decorator';
import { AuthErrorDefine } from './Errors/AuthErrorDefine';

Expand Down
5 changes: 2 additions & 3 deletions src/auth/dtos/AdminSendValidationNumber.response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { Exclude, Expose } from 'class-transformer';
import { IsEmail, IsMobilePhone } from 'class-validator';
import { Exclude } from 'class-transformer';

export class ResponseAdminSendValidationNumberDto {
// 직렬화
Expand All @@ -11,6 +10,6 @@ export class ResponseAdminSendValidationNumberDto {
isArray: true,
example: 'asdf'
})
@Expose()
@Exclude()
validationNumber: string;
}
2 changes: 1 addition & 1 deletion src/auth/dtos/RequestValidation.response.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class ResponseRequestValidationDto {
phoneNumber: string;

@ApiProperty({ description: '테스트용 인증번호', type: String })
@Expose()
@Exclude()
validationNumber: string;

@ApiProperty({ description: '이미 가입했는지에대한 정보', type: Boolean })
Expand Down
30 changes: 15 additions & 15 deletions src/common/utils/makeInstanceByApiProperty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ export function makeInstanceByApiProperty<T>(
// mappingDto 를 만듬
for (const property of properties) {
const propertyType = property.type;
console.log(
'fiste',
propertyType,
property,
mappingDto[property.fieldName]
);
// console.log(
// 'fiste',
// propertyType,
// property,
// mappingDto[property.fieldName]
// );

// property.type apiproperty에 type 을 기술 않할 수 있으므로 undefiend 체크
if (propertyType) {
Expand All @@ -131,24 +131,24 @@ export function makeInstanceByApiProperty<T>(
} else {
mappingDto[property.fieldName] = property.description;
}
console.log(
'fiste',
propertyType,
property,
mappingDto[property.fieldName]
);
// console.log(
// 'fiste',
// propertyType,
// property,
// mappingDto[property.fieldName]
// );
} else if (propertyType === 'number') {
// 숫자형태의 enum
if (typeof property.example !== 'undefined') {
mappingDto[property.fieldName] = property.example;
} else {
mappingDto[property.fieldName] = property.description;
}
console.log('fiste', propertyType, mappingDto[property.fieldName]);
// console.log('fiste', propertyType, mappingDto[property.fieldName]);
} else if (isPrimitiveType(propertyType)) {
// 원시타입 [String, Boolean, Number]

console.log('asdfasdfas', property, propertyType);
// console.log('asdfasdfas', property, propertyType);
if (typeof property.example !== 'undefined') {
mappingDto[property.fieldName] = property.example;
} else {
Expand All @@ -159,7 +159,7 @@ export function makeInstanceByApiProperty<T>(
// 익명함수를 실행시켜 안에 Dto 타입을 가져옵니다.

const constructorType = (propertyType as Function)();
console.log('fiste', propertyType, property, constructorType);
// console.log('fiste', propertyType, property, constructorType);

if (Array.isArray(constructorType)) {
mappingDto[property.fieldName] = [
Expand Down
26 changes: 10 additions & 16 deletions src/database/repositories/comment.repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Role } from 'src/common/consts/enum';
import { QueryBuilder, Repository } from 'typeorm';
import { Repository } from 'typeorm';
import { Comment } from '../entities/comment.entity';
import { User } from '../entities/user.entity';
import { RequestCommentDto } from 'src/users/dtos/Comment.request.dto';
Expand Down Expand Up @@ -83,9 +82,8 @@ export class CommentRepository {
// 응원 댓글 갯수 조회
async getCommentNum() {
const queryBuilder = this.commentRepository.createQueryBuilder('comment');

queryBuilder
.getMany();

queryBuilder.getMany();

const commentNum = await queryBuilder.getCount();
const ret_commentNum = {
Expand All @@ -100,13 +98,10 @@ export class CommentRepository {
const { take } = requestRandomCommentDto;
const queryBuilder = this.commentRepository.createQueryBuilder('comment');

queryBuilder
.orderBy('RANDOM()')
.limit(take);
queryBuilder.orderBy('RANDOM()').limit(take);


const { entities } = await queryBuilder.getRawAndEntities();

return plainToInstance(ResponseRandomCommentDto, entities);
}

Expand All @@ -120,20 +115,19 @@ export class CommentRepository {
.orderBy('RANDOM()')
.limit(take);


const { entities } = await queryBuilder.getRawAndEntities();
console.log(entities);
const comments = entities.map(function(comment) {
// console.log(entities);
const comments = entities.map(function (comment) {
const userInfo = plainToInstance(UserProfileDto, comment.user);
const ret_comment = {
id: comment.id,
content: comment.content,
nickName: comment.nickName,
createdAt: comment.createdAt,
userInfo,
}
userInfo
};
return ret_comment;
})
});
return plainToInstance(ResponseRandomCommentUserDto, comments);
}

Expand Down
9 changes: 6 additions & 3 deletions src/orders/orders.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import {
Patch,
Post,
Query,
UseGuards,
UsePipes,
ValidationPipe
UseGuards
} from '@nestjs/common';
import {
ApiBearerAuth,
Expand Down Expand Up @@ -38,6 +36,9 @@ import { OrderFindDto } from './dtos/order-find.dto';
import { UpdateOrderStatusDto } from './dtos/update-order-status.dto';
import { ReportDto } from './dtos/report.dto';
import { SuccessResponse } from 'src/common/decorators/SuccessResponse.decorator';
import { ThrottlerBehindProxyGuard } from 'src/auth/guards/TrottlerBehindProxy.guard';
import { ErrorResponse } from 'src/common/decorators/ErrorResponse.decorator';
import { AuthErrorDefine } from 'src/auth/Errors/AuthErrorDefine';

@ApiTags('orders')
@ApiBearerAuth('accessToken')
Expand All @@ -61,6 +62,8 @@ export class OrdersController {
status: 401,
description: 'AccessToken 권한이 없을 경우'
})
@UseGuards(ThrottlerBehindProxyGuard)
@ErrorResponse(HttpStatus.TOO_MANY_REQUESTS, [AuthErrorDefine['Auth-9000']])
@Post('')
createOrder(
@Body() requestOrderDto: RequestOrderDto,
Expand Down
5 changes: 2 additions & 3 deletions src/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
Post,
Query,
UseGuards,
Patch,
Req,
Delete,
Body,
HttpStatus
Expand Down Expand Up @@ -91,7 +89,7 @@ export class UsersController {
@Roles(Role.Admin)
@Get('/all')
async getAllUserInfo(
@Query() userFindDto: UserFindDto,
@Query() userFindDto: UserFindDto,
@Query() pageOptionsDto: PageOptionsDto
) {
return await this.userService.getAllUserInfo(userFindDto, pageOptionsDto);
Expand Down Expand Up @@ -196,6 +194,7 @@ export class UsersController {
exampleTitle: '댓글 랜덤 조회'
}
])
@Roles(Role.Admin)
@Get('/random/comment/userInfo')
async getRandomCommentUser(
@Query() requestRandomCommentDto: RequestRandomCommentDto
Expand Down

0 comments on commit 4deb6d5

Please sign in to comment.