Skip to content

Commit

Permalink
feat(#46): limit 클라이언트 측에서 수치 정하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hobiJeong committed Nov 9, 2023
1 parent 7a2d21d commit 6b9f301
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { SearchModule } from './search/search.module';
UserModule,
TypeOrmModule.forRoot({
...TypeORMconfig, // TypeORM 설정 객체 확장
synchronize: true, // DB 동기화 여부 설정
synchronize: false, // DB 동기화 여부 설정
}),
// TypeOrmModule.forFeature([Image]),
ConfigModule.forRoot({
Expand Down
3 changes: 1 addition & 2 deletions src/config/typeorm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@ export const TypeORMconfig: TypeOrmModuleOptions = {
BoardNotification,
// BoardRepository,
], // 여기에 엔티티들을 추가해야 합니다.
synchronize: process.env.NODE_ENV === 'true',
logging: true,
synchronize: process.env.NODE_ENV === 'false',
};
16 changes: 14 additions & 2 deletions src/search/controllers/search.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ export class SearchController {
@Param('category') category: string,
@Query('searchQuery') searchQuery: string,
@Query('page', ParseIntPipe) page: number,
@Query('limit', ParseIntPipe) limit: number,
) {
return this.searchService.searchBoardsByHead(category, searchQuery, page);
return this.searchService.searchBoardsByHead(
category,
searchQuery,
page,
limit,
);
}

@ApiSearchBoardsByBody()
Expand All @@ -34,8 +40,14 @@ export class SearchController {
@Param('category') category: string,
@Query('searchQuery') searchQuery: string,
@Query('page', ParseIntPipe) page: number,
@Query('limit', ParseIntPipe) limit: number,
) {
return this.searchService.searchBoardsByBody(category, searchQuery, page);
return this.searchService.searchBoardsByBody(
category,
searchQuery,
page,
limit,
);
}

@Get('users')
Expand Down
6 changes: 4 additions & 2 deletions src/search/services/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export class SearchService {
category: string,
searchQuery: string,
page: number,
limit: number,
) {
const take = 16;
const take = limit;
const skip = page <= 0 ? (page = 0) : (page - 1) * take;

const [returnedBoards, total] =
Expand Down Expand Up @@ -71,8 +72,9 @@ export class SearchService {
category: string,
searchQuery: string,
page: number,
limit: number,
) {
const take = 16;
const take = limit;
const skip = page <= 0 ? (page = 0) : (page - 1) * take;

const [returnedBoards, total] =
Expand Down

0 comments on commit 6b9f301

Please sign in to comment.