wip add button and feed stuff
This commit is contained in:
parent
38d09a582c
commit
1c2d6d60a6
11 changed files with 211 additions and 46 deletions
|
@ -8,17 +8,35 @@ console.debug('API HOST IS', ApiHost)
|
|||
|
||||
export async function loadPostsForAuthor(
|
||||
authorId: string,
|
||||
count?: number,
|
||||
cursor?: string,
|
||||
cursor: string | null,
|
||||
amount: number | null,
|
||||
): Promise<components['schemas']['GetAuthorPostsResponse']> {
|
||||
const url = new URL(`authors/${authorId}/posts`, ApiHost)
|
||||
if (count != null) url.searchParams.set('count', count.toString())
|
||||
if (amount != null) url.searchParams.set('amount', amount.toString())
|
||||
|
||||
if (cursor != null) url.searchParams.set('cursor', cursor)
|
||||
|
||||
const res = await doGetRequest(url)
|
||||
|
||||
return res as components['schemas']['GetAuthorPostsResponse']
|
||||
}
|
||||
|
||||
export async function loadPublicFeed(
|
||||
cursor: string | null,
|
||||
amount: number | null,
|
||||
): Promise<components['schemas']['GetAllPublicPostsResponse']> {
|
||||
const url = new URL(`posts`, ApiHost)
|
||||
if (amount != null) url.searchParams.set('amount', amount.toString())
|
||||
|
||||
if (cursor) url.searchParams.set('cursor', cursor)
|
||||
|
||||
const request = new Request(url)
|
||||
const res = await doGetRequest(url)
|
||||
|
||||
const response = await fetch(request)
|
||||
return res as components['schemas']['GetAllPublicPostsResponse']
|
||||
}
|
||||
|
||||
async function doGetRequest(url: URL): Promise<unknown> {
|
||||
const response = await fetch(new Request(url))
|
||||
|
||||
if (!response.ok) throw new Error(await response.text())
|
||||
|
||||
|
|
|
@ -6,7 +6,31 @@ export interface paths {
|
|||
path?: never
|
||||
cookie?: never
|
||||
}
|
||||
get?: never
|
||||
get: {
|
||||
parameters: {
|
||||
query?: {
|
||||
Cursor?: string
|
||||
Amount?: number
|
||||
}
|
||||
header?: never
|
||||
path?: never
|
||||
cookie?: never
|
||||
}
|
||||
requestBody?: never
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown
|
||||
}
|
||||
content: {
|
||||
'text/plain': components['schemas']['GetAllPublicPostsResponse']
|
||||
'application/json': components['schemas']['GetAllPublicPostsResponse']
|
||||
'text/json': components['schemas']['GetAllPublicPostsResponse']
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
put?: never
|
||||
post: {
|
||||
parameters: {
|
||||
|
@ -53,7 +77,7 @@ export interface paths {
|
|||
parameters: {
|
||||
query?: {
|
||||
Cursor?: string
|
||||
Count?: number
|
||||
Amount?: number
|
||||
}
|
||||
header?: never
|
||||
path: {
|
||||
|
@ -106,9 +130,26 @@ export interface components {
|
|||
/** Format: uuid */
|
||||
postId: string
|
||||
}
|
||||
GetAllPublicPostsResponse: {
|
||||
posts: components['schemas']['PublicPostDto'][]
|
||||
}
|
||||
GetAuthorPostsResponse: {
|
||||
posts: components['schemas']['AuthorPostDto'][]
|
||||
}
|
||||
PublicPostAuthorDto: {
|
||||
/** Format: uuid */
|
||||
authorId: string
|
||||
username: string
|
||||
}
|
||||
PublicPostDto: {
|
||||
authorDto: components['schemas']['PublicPostAuthorDto']
|
||||
/** Format: uuid */
|
||||
postId: string
|
||||
content: string
|
||||
media: string[]
|
||||
/** Format: date-time */
|
||||
createdAt: string
|
||||
}
|
||||
}
|
||||
responses: never
|
||||
parameters: never
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue