invidious: move searching to backend
This commit is contained in:
@@ -33,6 +33,19 @@ export interface MetadataUpdateEvent {
|
||||
};
|
||||
}
|
||||
|
||||
export interface SearchResult {
|
||||
type: string;
|
||||
title: string;
|
||||
author: string;
|
||||
mediaUrl: string;
|
||||
thumbnailUrl: string;
|
||||
}
|
||||
|
||||
export interface SearchResponse {
|
||||
success: boolean;
|
||||
results: SearchResult[];
|
||||
}
|
||||
|
||||
export const API = {
|
||||
async getPlaylist(): Promise<PlaylistItem[]> {
|
||||
const response = await fetch('/api/playlist');
|
||||
@@ -90,6 +103,11 @@ export const API = {
|
||||
});
|
||||
},
|
||||
|
||||
async search(query: string): Promise<SearchResponse> {
|
||||
const response = await fetch(`/api/search?q=${encodeURIComponent(query)}`);
|
||||
return response.json();
|
||||
},
|
||||
|
||||
subscribeToEvents(onMessage: (event: any) => void): WebSocket {
|
||||
const ws = new WebSocket(`ws://${window.location.host}/api/events`);
|
||||
ws.onmessage = (event) => {
|
||||
|
||||
Reference in New Issue
Block a user