From fa6adedc42e9c6ec39cc30df16b54900c220b094 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 20 Dec 2021 00:15:20 +0100 Subject: refactor: rewrite types and services I was repeating myself a lot in services. So I rewrited the different functions to improve readability and I extracted some formatting functions to put them in utils. I also rewrited/reorganized some types to keep consistent names. --- src/ts/types/blog.ts | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) (limited to 'src/ts/types/blog.ts') diff --git a/src/ts/types/blog.ts b/src/ts/types/blog.ts index 32fa9b8..7325ddf 100644 --- a/src/ts/types/blog.ts +++ b/src/ts/types/blog.ts @@ -1,47 +1,29 @@ -import { - ArticlePreview, - ArticlePreviewResponse, - ArticleSlug, -} from './articles'; -import { PageInfo } from './pagination'; - -export type PostsListEdge = { - cursor: string; - node: ArticlePreviewResponse; -}; - -export type PostsListResponse = { - posts: { - edges: PostsListEdge[]; - pageInfo: PageInfo; - }; -}; +import { PageInfo, Slug } from './app'; +import { ArticlePreview, RawArticlePreview } from './articles'; export type PostsList = { posts: ArticlePreview[]; pageInfo: PageInfo; }; -export type FetchPostsListReturn = ( - first?: number, - after?: string -) => Promise; - -type PostsListProps = { - first?: number; - after?: string; +export type PostsListEdges = { + cursor: string; + node: RawArticlePreview; }; -export type GetPostsListReturn = (props: PostsListProps) => Promise; - -export type BlogPageProps = { - fallback: PostsList; +export type RawPostsList = { + posts: { + edges: PostsListEdges[]; + pageInfo: PageInfo; + }; }; -export type AllPostsSlugResponse = { +export type AllPostsSlug = { posts: { - nodes: ArticleSlug[]; + nodes: Slug[]; }; }; -export type FetchAllPostsSlugReturn = () => Promise; +export type BlogPageProps = { + fallback: PostsList; +}; -- cgit v1.2.3