Skip to content

Commit

Permalink
feat: 검색 mock handler 내 response dto 타입 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
suhwan2004 committed Nov 17, 2024
1 parent a1ac725 commit 9fc03a5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app/mocks/data/feed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IFeed } from '@/entities/feed';
import { IImage } from '@/shared/types/image';
import { IImage } from '@/shared/types';

import { userMockData } from './user';

Expand Down
6 changes: 4 additions & 2 deletions src/app/mocks/handlers/search.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Fuse from 'fuse.js';
import { http } from 'msw';

import { ISearchFeedResDTO, ISearchUserResDTO } from '@/entities/search';

import { feedMockData, userMockData } from '../data';
import { createHttpErrorResponse, createHttpSuccessResponse } from '../lib';

Expand Down Expand Up @@ -28,7 +30,7 @@ export const searchHandlers = [
const totalFeeds = contents.length;
const hasNextPage = totalFeeds > page * size;

return createHttpSuccessResponse({
return createHttpSuccessResponse<ISearchFeedResDTO>({
feed: {
contents,
currentPageNumber: page,
Expand Down Expand Up @@ -62,7 +64,7 @@ export const searchHandlers = [
const totalFeeds = contents.length;
const hasNextPage = totalFeeds > page * size;

return createHttpSuccessResponse({
return createHttpSuccessResponse<ISearchUserResDTO>({
user: {
contents,
currentPageNumber: page,
Expand Down
11 changes: 6 additions & 5 deletions src/entities/search/model/search.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import { IFeed } from '@/entities/feed';
import { IUser } from '@/entities/user';

//피드 검색
export interface ISearchFeedResDTO extends ISearchCommonResDTO {
contents: IFeed;
export interface ISearchFeedResDTO {
feed: ICommonSearchData<IFeed[]>;
}

//유저 검색
export interface ISearchUserResDTO extends ISearchCommonResDTO {
contents: IUser;
export interface ISearchUserResDTO {
user: ICommonSearchData<IUser[]>;
}

export interface ISearchCommonResDTO {
export interface ICommonSearchData<T> {
contents: T;
currentPageNumber: number;
pageSize: number;
numberOfElements: number;
Expand Down

0 comments on commit 9fc03a5

Please sign in to comment.