new features, bookstack
This commit is contained in:
24
frontend/src/services/bookstack.ts
Normal file
24
frontend/src/services/bookstack.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { api } from './api';
|
||||
import type { BookStackRecentResponse, BookStackSearchResponse } from '../types/bookstack.types';
|
||||
|
||||
interface ApiResponse<T> {
|
||||
success: boolean;
|
||||
data: T;
|
||||
configured: boolean;
|
||||
}
|
||||
|
||||
export const bookstackApi = {
|
||||
getRecent(): Promise<BookStackRecentResponse> {
|
||||
return api
|
||||
.get<ApiResponse<BookStackRecentResponse['data']>>('/api/bookstack/recent')
|
||||
.then((r) => ({ configured: r.data.configured, data: r.data.data }));
|
||||
},
|
||||
|
||||
search(query: string): Promise<BookStackSearchResponse> {
|
||||
return api
|
||||
.get<ApiResponse<BookStackSearchResponse['data']>>('/api/bookstack/search', {
|
||||
params: { query },
|
||||
})
|
||||
.then((r) => ({ configured: r.data.configured, data: r.data.data }));
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user