feat: 시안 B 화면을 기본 화면으로, Hey API로 백엔드 연결
- 예전 화면(/, /a)과 목업 데이터를 지우고 시안 B 를 / 로 - @hey-api/openapi-ts 로 타입·TanStack Query 함수 생성, 토큰·401 갱신 처리 - 공유는 기본 공유창, 없으면 링크 복사 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e134295ce5
commit
f8b47f064a
147 files changed
+12350
No files matched your search
@@ -0,0 +1,676 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import { type DefaultError, type InfiniteData, infiniteQueryOptions, queryOptions, type UseMutationOptions } from '@tanstack/react-query';
|
||||
|
||||
import { client } from '../client.gen';
|
||||
import { addComment, deleteComment, getArticle, getFeed, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getWeatherNow, getWeatherToday, getWeek, healthzHealthzGet, likeComment, likePost, listArticles, listComments, listEvents, listIndices, listPlaces, listRegions, listSaved, login, me, nearestRegion, type Options, refresh, savePost, signup, unlikeComment, unlikePost, unsavePost } from '../sdk.gen';
|
||||
import type { AddCommentData, AddCommentError, AddCommentResponse, DeleteCommentData, DeleteCommentError, DeleteCommentResponse, GetArticleData, GetArticleError, GetArticleResponse, GetFeedData, GetFeedError, GetFeedResponse, GetIndexData, GetIndexError, GetIndexResponse, GetPostData, GetPostError, GetPostResponse, GetSeasonWeekData, GetSeasonWeekResponse, GetSkyData, GetSkyError, GetSkyRankingData, GetSkyRankingResponse, GetSkyResponse, GetWeatherNowData, GetWeatherNowError, GetWeatherNowResponse, GetWeatherTodayData, GetWeatherTodayError, GetWeatherTodayResponse, GetWeekData, GetWeekError, GetWeekResponse, HealthzHealthzGetData, HealthzHealthzGetResponse, LikeCommentData, LikeCommentError, LikeCommentResponse, LikePostData, LikePostError, LikePostResponse, ListArticlesData, ListArticlesError, ListArticlesResponse, ListCommentsData, ListCommentsError, ListCommentsResponse, ListEventsData, ListEventsError, ListEventsResponse, ListIndicesData, ListIndicesError, ListIndicesResponse, ListPlacesData, ListPlacesError, ListPlacesResponse, ListRegionsData, ListRegionsError, ListRegionsResponse, ListSavedData, ListSavedError, ListSavedResponse, LoginData, LoginError, LoginResponse, MeData, MeError, MeResponse, NearestRegionData, NearestRegionError, NearestRegionResponse, RefreshData, RefreshError, RefreshResponse, SavePostData, SavePostError, SavePostResponse, SignupData, SignupError, SignupResponse, UnlikeCommentData, UnlikeCommentError, UnlikeCommentResponse, UnlikePostData, UnlikePostError, UnlikePostResponse, UnsavePostData, UnsavePostError, UnsavePostResponse } from '../types.gen';
|
||||
|
||||
export type QueryKey<TOptions extends Options> = [
|
||||
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
|
||||
_id: string;
|
||||
_infinite?: boolean;
|
||||
tags?: ReadonlyArray<string>;
|
||||
}
|
||||
];
|
||||
|
||||
const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray<string>): [
|
||||
QueryKey<TOptions>[0]
|
||||
] => {
|
||||
const params: QueryKey<TOptions>[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey<TOptions>[0];
|
||||
if (infinite) {
|
||||
params._infinite = infinite;
|
||||
}
|
||||
if (tags) {
|
||||
params.tags = tags;
|
||||
}
|
||||
if (options?.body) {
|
||||
params.body = options.body;
|
||||
}
|
||||
if (options?.headers) {
|
||||
params.headers = options.headers;
|
||||
}
|
||||
if (options?.path) {
|
||||
params.path = options.path;
|
||||
}
|
||||
if (options?.query) {
|
||||
params.query = options.query;
|
||||
}
|
||||
return [params];
|
||||
};
|
||||
|
||||
export const listRegionsQueryKey = (options?: Options<ListRegionsData>) => createQueryKey('listRegions', options);
|
||||
|
||||
/**
|
||||
* 구 목록
|
||||
*/
|
||||
export const listRegionsOptions = (options?: Options<ListRegionsData>) => queryOptions<ListRegionsResponse, ListRegionsError, ListRegionsResponse, ReturnType<typeof listRegionsQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await listRegions({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: listRegionsQueryKey(options)
|
||||
});
|
||||
|
||||
export const nearestRegionQueryKey = (options: Options<NearestRegionData>) => createQueryKey('nearestRegion', options);
|
||||
|
||||
/**
|
||||
* 위치에서 가장 가까운 구
|
||||
*/
|
||||
export const nearestRegionOptions = (options: Options<NearestRegionData>) => queryOptions<NearestRegionResponse, NearestRegionError, NearestRegionResponse, ReturnType<typeof nearestRegionQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await nearestRegion({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: nearestRegionQueryKey(options)
|
||||
});
|
||||
|
||||
export const getWeatherTodayQueryKey = (options: Options<GetWeatherTodayData>) => createQueryKey('getWeatherToday', options);
|
||||
|
||||
/**
|
||||
* 오늘 3시간 칸 날씨
|
||||
*/
|
||||
export const getWeatherTodayOptions = (options: Options<GetWeatherTodayData>) => queryOptions<GetWeatherTodayResponse, GetWeatherTodayError, GetWeatherTodayResponse, ReturnType<typeof getWeatherTodayQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getWeatherToday({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getWeatherTodayQueryKey(options)
|
||||
});
|
||||
|
||||
export const getWeatherNowQueryKey = (options: Options<GetWeatherNowData>) => createQueryKey('getWeatherNow', options);
|
||||
|
||||
/**
|
||||
* 지금 비 올까: 2시간 비, 내일 출퇴근, 미세먼지, 특보
|
||||
*/
|
||||
export const getWeatherNowOptions = (options: Options<GetWeatherNowData>) => queryOptions<GetWeatherNowResponse, GetWeatherNowError, GetWeatherNowResponse, ReturnType<typeof getWeatherNowQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getWeatherNow({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getWeatherNowQueryKey(options)
|
||||
});
|
||||
|
||||
export const getSkyQueryKey = (options: Options<GetSkyData>) => createQueryKey('getSky', options);
|
||||
|
||||
/**
|
||||
* 노을·일출 점수, 3컷, 가까운 명소, 앞으로 3일
|
||||
*/
|
||||
export const getSkyOptions = (options: Options<GetSkyData>) => queryOptions<GetSkyResponse, GetSkyError, GetSkyResponse, ReturnType<typeof getSkyQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getSky({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getSkyQueryKey(options)
|
||||
});
|
||||
|
||||
export const getSkyRankingQueryKey = (options?: Options<GetSkyRankingData>) => createQueryKey('getSkyRanking', options);
|
||||
|
||||
/**
|
||||
* 전국 노을 순위 (대표 30곳)
|
||||
*/
|
||||
export const getSkyRankingOptions = (options?: Options<GetSkyRankingData>) => queryOptions<GetSkyRankingResponse, DefaultError, GetSkyRankingResponse, ReturnType<typeof getSkyRankingQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getSkyRanking({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getSkyRankingQueryKey(options)
|
||||
});
|
||||
|
||||
export const listIndicesQueryKey = (options: Options<ListIndicesData>) => createQueryKey('listIndices', options);
|
||||
|
||||
/**
|
||||
* 지수 목록 (점수순, 1~3위, 오늘 날씨 점수)
|
||||
*/
|
||||
export const listIndicesOptions = (options: Options<ListIndicesData>) => queryOptions<ListIndicesResponse, ListIndicesError, ListIndicesResponse, ReturnType<typeof listIndicesQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await listIndices({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: listIndicesQueryKey(options)
|
||||
});
|
||||
|
||||
export const getIndexQueryKey = (options: Options<GetIndexData>) => createQueryKey('getIndex', options);
|
||||
|
||||
/**
|
||||
* 지수 계산 근거
|
||||
*/
|
||||
export const getIndexOptions = (options: Options<GetIndexData>) => queryOptions<GetIndexResponse, GetIndexError, GetIndexResponse, ReturnType<typeof getIndexQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getIndex({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getIndexQueryKey(options)
|
||||
});
|
||||
|
||||
export const getWeekQueryKey = (options: Options<GetWeekData>) => createQueryKey('getWeek', options);
|
||||
|
||||
/**
|
||||
* 7일 날씨와 그날 추천
|
||||
*/
|
||||
export const getWeekOptions = (options: Options<GetWeekData>) => queryOptions<GetWeekResponse, GetWeekError, GetWeekResponse, ReturnType<typeof getWeekQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getWeek({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getWeekQueryKey(options)
|
||||
});
|
||||
|
||||
export const listPlacesQueryKey = (options: Options<ListPlacesData>) => createQueryKey('listPlaces', options);
|
||||
|
||||
/**
|
||||
* 날씨 맞춤 데이트 명소
|
||||
*/
|
||||
export const listPlacesOptions = (options: Options<ListPlacesData>) => queryOptions<ListPlacesResponse, ListPlacesError, ListPlacesResponse, ReturnType<typeof listPlacesQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await listPlaces({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: listPlacesQueryKey(options)
|
||||
});
|
||||
|
||||
export const listEventsQueryKey = (options: Options<ListEventsData>) => createQueryKey('listEvents', options);
|
||||
|
||||
/**
|
||||
* 앞으로 30일 축제·행사
|
||||
*/
|
||||
export const listEventsOptions = (options: Options<ListEventsData>) => queryOptions<ListEventsResponse, ListEventsError, ListEventsResponse, ReturnType<typeof listEventsQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await listEvents({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: listEventsQueryKey(options)
|
||||
});
|
||||
|
||||
export const getSeasonWeekQueryKey = (options?: Options<GetSeasonWeekData>) => createQueryKey('getSeasonWeek', options);
|
||||
|
||||
/**
|
||||
* 이번 주 계절 책: 시, 절기, 계절 소식
|
||||
*/
|
||||
export const getSeasonWeekOptions = (options?: Options<GetSeasonWeekData>) => queryOptions<GetSeasonWeekResponse, DefaultError, GetSeasonWeekResponse, ReturnType<typeof getSeasonWeekQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getSeasonWeek({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getSeasonWeekQueryKey(options)
|
||||
});
|
||||
|
||||
export const listArticlesQueryKey = (options?: Options<ListArticlesData>) => createQueryKey('listArticles', options);
|
||||
|
||||
/**
|
||||
* 읽을거리 목록
|
||||
*/
|
||||
export const listArticlesOptions = (options?: Options<ListArticlesData>) => queryOptions<ListArticlesResponse, ListArticlesError, ListArticlesResponse, ReturnType<typeof listArticlesQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await listArticles({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: listArticlesQueryKey(options)
|
||||
});
|
||||
|
||||
export const getArticleQueryKey = (options: Options<GetArticleData>) => createQueryKey('getArticle', options);
|
||||
|
||||
/**
|
||||
* 읽을거리 본문
|
||||
*/
|
||||
export const getArticleOptions = (options: Options<GetArticleData>) => queryOptions<GetArticleResponse, GetArticleError, GetArticleResponse, ReturnType<typeof getArticleQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getArticle({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getArticleQueryKey(options)
|
||||
});
|
||||
|
||||
export const getFeedQueryKey = (options: Options<GetFeedData>) => createQueryKey('getFeed', options);
|
||||
|
||||
/**
|
||||
* 메인 피드: 하늘 영역, 오늘의 각, 오늘 포스트 전부, 띠
|
||||
*/
|
||||
export const getFeedOptions = (options: Options<GetFeedData>) => queryOptions<GetFeedResponse, GetFeedError, GetFeedResponse, ReturnType<typeof getFeedQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getFeed({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getFeedQueryKey(options)
|
||||
});
|
||||
|
||||
export const getPostQueryKey = (options: Options<GetPostData>) => createQueryKey('getPost', options);
|
||||
|
||||
/**
|
||||
* 포스트 하나 (공유 링크로 들어왔을 때)
|
||||
*/
|
||||
export const getPostOptions = (options: Options<GetPostData>) => queryOptions<GetPostResponse, GetPostError, GetPostResponse, ReturnType<typeof getPostQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getPost({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getPostQueryKey(options)
|
||||
});
|
||||
|
||||
/**
|
||||
* 회원가입 (아이디 영문 소문자·숫자·_ 4~20자, 비밀번호 8자 이상, 닉네임 2~12자)
|
||||
*/
|
||||
export const signupMutation = (options?: Partial<Options<SignupData>>): UseMutationOptions<SignupResponse, SignupError, Options<SignupData>> => {
|
||||
const mutationOptions: UseMutationOptions<SignupResponse, SignupError, Options<SignupData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await signup({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 로그인
|
||||
*/
|
||||
export const loginMutation = (options?: Partial<Options<LoginData>>): UseMutationOptions<LoginResponse, LoginError, Options<LoginData>> => {
|
||||
const mutationOptions: UseMutationOptions<LoginResponse, LoginError, Options<LoginData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await login({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 토큰 재발급
|
||||
*/
|
||||
export const refreshMutation = (options?: Partial<Options<RefreshData>>): UseMutationOptions<RefreshResponse, RefreshError, Options<RefreshData>> => {
|
||||
const mutationOptions: UseMutationOptions<RefreshResponse, RefreshError, Options<RefreshData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await refresh({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const meQueryKey = (options?: Options<MeData>) => createQueryKey('me', options);
|
||||
|
||||
/**
|
||||
* 내 정보
|
||||
*/
|
||||
export const meOptions = (options?: Options<MeData>) => queryOptions<MeResponse, MeError, MeResponse, ReturnType<typeof meQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await me({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: meQueryKey(options)
|
||||
});
|
||||
|
||||
/**
|
||||
* 좋아요 취소
|
||||
*/
|
||||
export const unlikePostMutation = (options?: Partial<Options<UnlikePostData>>): UseMutationOptions<UnlikePostResponse, UnlikePostError, Options<UnlikePostData>> => {
|
||||
const mutationOptions: UseMutationOptions<UnlikePostResponse, UnlikePostError, Options<UnlikePostData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await unlikePost({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 좋아요
|
||||
*/
|
||||
export const likePostMutation = (options?: Partial<Options<LikePostData>>): UseMutationOptions<LikePostResponse, LikePostError, Options<LikePostData>> => {
|
||||
const mutationOptions: UseMutationOptions<LikePostResponse, LikePostError, Options<LikePostData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await likePost({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 저장 취소
|
||||
*/
|
||||
export const unsavePostMutation = (options?: Partial<Options<UnsavePostData>>): UseMutationOptions<UnsavePostResponse, UnsavePostError, Options<UnsavePostData>> => {
|
||||
const mutationOptions: UseMutationOptions<UnsavePostResponse, UnsavePostError, Options<UnsavePostData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await unsavePost({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 저장
|
||||
*/
|
||||
export const savePostMutation = (options?: Partial<Options<SavePostData>>): UseMutationOptions<SavePostResponse, SavePostError, Options<SavePostData>> => {
|
||||
const mutationOptions: UseMutationOptions<SavePostResponse, SavePostError, Options<SavePostData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await savePost({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const listSavedQueryKey = (options?: Options<ListSavedData>) => createQueryKey('listSaved', options);
|
||||
|
||||
/**
|
||||
* 내가 저장한 포스트
|
||||
*/
|
||||
export const listSavedOptions = (options?: Options<ListSavedData>) => queryOptions<ListSavedResponse, ListSavedError, ListSavedResponse, ReturnType<typeof listSavedQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await listSaved({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: listSavedQueryKey(options)
|
||||
});
|
||||
|
||||
const createInfiniteParams = <K extends Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>>(queryKey: QueryKey<Options>, page: K) => {
|
||||
const params = { ...queryKey[0] };
|
||||
if (page.body) {
|
||||
params.body = {
|
||||
...queryKey[0].body as any,
|
||||
...page.body as any
|
||||
};
|
||||
}
|
||||
if (page.headers) {
|
||||
params.headers = {
|
||||
...queryKey[0].headers,
|
||||
...page.headers
|
||||
};
|
||||
}
|
||||
if (page.path) {
|
||||
params.path = {
|
||||
...queryKey[0].path as any,
|
||||
...page.path as any
|
||||
};
|
||||
}
|
||||
if (page.query) {
|
||||
params.query = {
|
||||
...queryKey[0].query as any,
|
||||
...page.query as any
|
||||
};
|
||||
}
|
||||
return params as unknown as typeof page;
|
||||
};
|
||||
|
||||
export const listSavedInfiniteQueryKey = (options?: Options<ListSavedData>): QueryKey<Options<ListSavedData>> => createQueryKey('listSaved', options, true);
|
||||
|
||||
/**
|
||||
* 내가 저장한 포스트
|
||||
*/
|
||||
export const listSavedInfiniteOptions = (options?: Options<ListSavedData>) => {
|
||||
const opts = infiniteQueryOptions<ListSavedResponse, ListSavedError, InfiniteData<ListSavedResponse>, QueryKey<Options<ListSavedData>>, number | null | Pick<QueryKey<Options<ListSavedData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
|
||||
// @ts-ignore
|
||||
{
|
||||
queryFn: async ({ pageParam, queryKey, signal }) => {
|
||||
// @ts-ignore
|
||||
const page: Pick<QueryKey<Options<ListSavedData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
|
||||
query: {
|
||||
cursor: pageParam
|
||||
}
|
||||
};
|
||||
const params = createInfiniteParams(queryKey, page);
|
||||
const { data } = await listSaved({
|
||||
...options,
|
||||
...params,
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: listSavedInfiniteQueryKey(options)
|
||||
});
|
||||
return opts as Omit<typeof opts, 'initialData'>;
|
||||
};
|
||||
|
||||
export const listCommentsQueryKey = (options: Options<ListCommentsData>) => createQueryKey('listComments', options);
|
||||
|
||||
/**
|
||||
* 댓글 목록 (로그인 없이 보기)
|
||||
*/
|
||||
export const listCommentsOptions = (options: Options<ListCommentsData>) => queryOptions<ListCommentsResponse, ListCommentsError, ListCommentsResponse, ReturnType<typeof listCommentsQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await listComments({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: listCommentsQueryKey(options)
|
||||
});
|
||||
|
||||
export const listCommentsInfiniteQueryKey = (options: Options<ListCommentsData>): QueryKey<Options<ListCommentsData>> => createQueryKey('listComments', options, true);
|
||||
|
||||
/**
|
||||
* 댓글 목록 (로그인 없이 보기)
|
||||
*/
|
||||
export const listCommentsInfiniteOptions = (options: Options<ListCommentsData>) => {
|
||||
const opts = infiniteQueryOptions<ListCommentsResponse, ListCommentsError, InfiniteData<ListCommentsResponse>, QueryKey<Options<ListCommentsData>>, number | null | Pick<QueryKey<Options<ListCommentsData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
|
||||
// @ts-ignore
|
||||
{
|
||||
queryFn: async ({ pageParam, queryKey, signal }) => {
|
||||
// @ts-ignore
|
||||
const page: Pick<QueryKey<Options<ListCommentsData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
|
||||
query: {
|
||||
cursor: pageParam
|
||||
}
|
||||
};
|
||||
const params = createInfiniteParams(queryKey, page);
|
||||
const { data } = await listComments({
|
||||
...options,
|
||||
...params,
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: listCommentsInfiniteQueryKey(options)
|
||||
});
|
||||
return opts as Omit<typeof opts, 'initialData'>;
|
||||
};
|
||||
|
||||
/**
|
||||
* 댓글 쓰기 (60자)
|
||||
*/
|
||||
export const addCommentMutation = (options?: Partial<Options<AddCommentData>>): UseMutationOptions<AddCommentResponse, AddCommentError, Options<AddCommentData>> => {
|
||||
const mutationOptions: UseMutationOptions<AddCommentResponse, AddCommentError, Options<AddCommentData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await addComment({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 내 댓글 지우기
|
||||
*/
|
||||
export const deleteCommentMutation = (options?: Partial<Options<DeleteCommentData>>): UseMutationOptions<DeleteCommentResponse, DeleteCommentError, Options<DeleteCommentData>> => {
|
||||
const mutationOptions: UseMutationOptions<DeleteCommentResponse, DeleteCommentError, Options<DeleteCommentData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await deleteComment({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 댓글 좋아요 취소
|
||||
*/
|
||||
export const unlikeCommentMutation = (options?: Partial<Options<UnlikeCommentData>>): UseMutationOptions<UnlikeCommentResponse, UnlikeCommentError, Options<UnlikeCommentData>> => {
|
||||
const mutationOptions: UseMutationOptions<UnlikeCommentResponse, UnlikeCommentError, Options<UnlikeCommentData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await unlikeComment({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 댓글 좋아요
|
||||
*/
|
||||
export const likeCommentMutation = (options?: Partial<Options<LikeCommentData>>): UseMutationOptions<LikeCommentResponse, LikeCommentError, Options<LikeCommentData>> => {
|
||||
const mutationOptions: UseMutationOptions<LikeCommentResponse, LikeCommentError, Options<LikeCommentData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await likeComment({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const healthzHealthzGetQueryKey = (options?: Options<HealthzHealthzGetData>) => createQueryKey('healthzHealthzGet', options);
|
||||
|
||||
/**
|
||||
* 헬스체크
|
||||
*/
|
||||
export const healthzHealthzGetOptions = (options?: Options<HealthzHealthzGetData>) => queryOptions<HealthzHealthzGetResponse, DefaultError, HealthzHealthzGetResponse, ReturnType<typeof healthzHealthzGetQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await healthzHealthzGet({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: healthzHealthzGetQueryKey(options)
|
||||
});
|
||||
Reference in new issue
Block a user