Skip to content

Commit

Permalink
Merge branch 'epic/FE-51--API' into merge/FE-51
Browse files Browse the repository at this point in the history
  • Loading branch information
newjinlee authored Jul 20, 2024
2 parents cdf96d7 + f78ea94 commit bdea96c
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 bdea96c

Please sign in to comment.