Skip to content

Commit

Permalink
FE-52 ✨에피그램 목록조회 API (#34)
Browse files Browse the repository at this point in the history
* FE-52 feat: api schema 작성

* FE-52 ✨feat: getEpigrams api 작성

* FE-522 ✨fix:  default export로 변경

* FE-52 ✨test: 테스트 코드 작성

* FE-52 ✨feat: BaseUrl, TeamID 상수 추가 및 axios baseTRL 수정

* FE-52 ✨fix: schema 및 apis 파일 수정

* FE-52 ✨test:  테스트 코드 삭제

* FE-52 ✨fix: .env파일 생성 및 BaseURL 수정

* FE-52 ✨fix: limit 타입  수정(optional 삭제)

* FE-52 ✨text: 테 테스트코드 삭제

* FE-52 ✨fix: api GET요청 주소 수정('epigrams' -> '/epigrams')
  • Loading branch information
imsoohyeok authored Jul 17, 2024
1 parent cdede81 commit f78ea94
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Empty file added src/apis/.http
Empty file.
12 changes: 12 additions & 0 deletions src/apis/getEpigrams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { GetEpigramsParamsType, GetEpigramsResponseType, GetEpigramsResponse } from '@/schema/epigrams';
import httpClient from '.';

const getEpigrams = async (params: GetEpigramsParamsType): Promise<GetEpigramsResponseType> => {
const response = await httpClient.get(`/epigrams`, { params });

// 데이터 일치하는지 확인
const parsedResponse = GetEpigramsResponse.parse(response.data);
return parsedResponse;
};

export default getEpigrams;
33 changes: 33 additions & 0 deletions src/schema/epigrams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as z from 'zod';

export const GetEpigramsParams = z.object({
limit: z.number(),
cursor: z.number().optional(),
keyword: z.string().optional(),
writerId: z.number().optional(),
});

export const GetEpigramsResponse = z.object({
totalCount: z.number(),
nextCursor: z.number(),
list: z.array(
z.object({
likeCount: z.number(),
tags: z.array(
z.object({
name: z.string(),
id: z.number(),
}),
),
writerId: z.number(),
referenceUrl: z.string(),
referenceTitle: z.string(),
author: z.string(),
content: z.string(),
id: z.number(),
}),
),
});

export type GetEpigramsParamsType = z.infer<typeof GetEpigramsParams>;
export type GetEpigramsResponseType = z.infer<typeof GetEpigramsResponse>;

0 comments on commit f78ea94

Please sign in to comment.