-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'epic/FE-51--API' into merge/FE-51
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; |