@@ -66,4 +66,17 @@ describe('test post client', () => {
|
||||
expect(data).toStrictEqual({ title: '1' })
|
||||
expect(data.$raw).toBeDefined()
|
||||
})
|
||||
|
||||
it('GET /posts/get-url/:slug', async () => {
|
||||
mockResponse('/posts/get-url/host-an-entire-Mix-Space-using-Docker', {
|
||||
path: '/website/host-an-entire-Mix-Space-using-Docker',
|
||||
})
|
||||
|
||||
const data = await client.post.getFullUrl(
|
||||
'host-an-entire-Mix-Space-using-Docker',
|
||||
)
|
||||
expect(data).toStrictEqual({
|
||||
path: '/website/host-an-entire-Mix-Space-using-Docker',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import type { IRequestAdapter } from '~/interfaces/adapter'
|
||||
import type { IController } from '~/interfaces/controller'
|
||||
import type { IRequestHandler } from '~/interfaces/request'
|
||||
import type { ActivityPresence, RoomsData } from '~/models/activity'
|
||||
import type {
|
||||
ActivityPresence,
|
||||
RecentActivities,
|
||||
RoomsData,
|
||||
} from '~/models/activity'
|
||||
import type { HTTPClient } from '../core'
|
||||
|
||||
import { autoBind } from '~/utils/auto-bind'
|
||||
@@ -87,4 +91,8 @@ export class ActivityController<ResponseWrapper> implements IController {
|
||||
async getRoomsInfo() {
|
||||
return this.proxy.rooms.get<RoomsData>()
|
||||
}
|
||||
|
||||
async getRecentActivities() {
|
||||
return this.proxy.recent.get<RecentActivities>()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,10 @@ import type { IRequestHandler, RequestProxyResult } from '~/interfaces/request'
|
||||
import type { SelectFields } from '~/interfaces/types'
|
||||
import type { ModelWithLiked, PaginateResult } from '~/models/base'
|
||||
import type { PostModel } from '~/models/post'
|
||||
import type { HTTPClient } from '../core/client'
|
||||
|
||||
import { autoBind } from '~/utils/auto-bind'
|
||||
|
||||
import { HTTPClient } from '../core/client'
|
||||
|
||||
declare module '../core/client' {
|
||||
interface HTTPClient<
|
||||
T extends IRequestAdapter = IRequestAdapter,
|
||||
@@ -86,4 +85,8 @@ export class PostController<ResponseWrapper> implements IController {
|
||||
getLatest() {
|
||||
return this.proxy.latest.get<ModelWithLiked<PostModel>>()
|
||||
}
|
||||
|
||||
getFullUrl(slug: string) {
|
||||
return this.proxy('get-url')(slug).get<{ path: string }>()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { CollectionRefTypes } from '@core/constants/db.constant'
|
||||
import type { CategoryModel } from './category'
|
||||
|
||||
export interface ActivityPresence {
|
||||
@@ -45,3 +46,54 @@ export interface RoomsData {
|
||||
pages: RoomOmittedPage[]
|
||||
}
|
||||
}
|
||||
|
||||
export interface RecentActivities {
|
||||
like: RecentLike[]
|
||||
comment: RecentComment[]
|
||||
recent: RecentRecent[]
|
||||
post: RecentPost[]
|
||||
note: RecentNote[]
|
||||
}
|
||||
|
||||
export interface RecentComment {
|
||||
created: string
|
||||
author: string
|
||||
text: string
|
||||
id: string
|
||||
title: string
|
||||
slug: string
|
||||
type: string
|
||||
}
|
||||
|
||||
export interface RecentLike {
|
||||
created: string
|
||||
id: string
|
||||
type: CollectionRefTypes.Post | CollectionRefTypes.Note
|
||||
nid?: number
|
||||
slug?: string
|
||||
}
|
||||
|
||||
export interface RecentNote {
|
||||
id: string
|
||||
created: string
|
||||
title: string
|
||||
modified: string
|
||||
nid: number
|
||||
}
|
||||
|
||||
export interface RecentPost {
|
||||
id: string
|
||||
created: string
|
||||
title: string
|
||||
modified: string
|
||||
slug: string
|
||||
}
|
||||
|
||||
export interface RecentRecent {
|
||||
id: string
|
||||
|
||||
content: string
|
||||
up: number
|
||||
down: number
|
||||
created: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user