/** * Google Custom Search Service * * Service for performing Google Custom Search queries. * * Note: This service is designed to be used from a backend API route. * In a Vite React app, you should create an API route in your backend * (e.g., Next.js API route, Express endpoint) that calls this service * and exposes it to the frontend. * * For direct client-side usage, use the googleSearchClient service instead. */ export interface GoogleSearchResultItem { title: string; link: string; snippet: string; displayLink?: string; htmlTitle?: string; htmlSnippet?: string; [key: string]: any; } export interface GoogleSearchResponse { items?: GoogleSearchResultItem[]; searchInformation?: { searchTime: number; formattedSearchTime: string; totalResults: string; formattedTotalResults: string; }; queries?: { request: Array<{ title: string; totalResults: string; searchTerms: string; }>; }; [key: string]: any; } /** * Server-side Google Custom Search * * This function should only be called from server-side code (API routes, server actions). * It requires GOOGLE_SEARCH_API_KEY and GOOGLE_SEARCH_ENGINE_ID environment variables. */ export declare function googleSiteSearch(query: string): Promise; /** * Client-side Google Search (via API route) * * Use this from React components to search via your backend API route. * The backend should call googleSiteSearch() and return the results. * * Example API route (Next.js): * // app/api/google/search/route.ts * import { googleSiteSearch } from '@/services/google-search.service'; * export async function GET(req: Request) { * const { searchParams } = new URL(req.url); * const q = searchParams.get('q'); * if (!q) return Response.json({ error: 'Missing query' }, { status: 400 }); * const items = await googleSiteSearch(q); * return Response.json({ ok: true, items }); * } */ export declare const googleSearchClient: { /** * Search via backend API route * * @param query - Search query string * @param apiEndpoint - Backend API endpoint (default: /api/google/search) * @returns Search results */ search: (query: string, apiEndpoint?: string) => Promise; }; //# sourceMappingURL=google-search.service.d.ts.map