chore: update Angular cache and TypeScript build info files
This commit is contained in:
@@ -10,18 +10,22 @@
|
||||
* @property {string=} type
|
||||
*/
|
||||
|
||||
/** @type {{ id: 'yt', label: string, search: (q: string, opts: { limit: number, page?: number }) => Promise<Suggestion[]> }} */
|
||||
/** @type {{ id: 'yt', label: string, search: (q: string, opts: { limit: number, page?: number, sort?: 'relevance'|'date'|'views' }) => Promise<Suggestion[]> }} */
|
||||
const handler = {
|
||||
id: 'yt',
|
||||
label: 'YouTube',
|
||||
async search(q, opts) {
|
||||
const { limit = 10 } = opts;
|
||||
const { limit = 10, sort = 'relevance' } = opts || {};
|
||||
try {
|
||||
const API_KEY = process.env.YOUTUBE_API_KEY;
|
||||
if (!API_KEY) {
|
||||
throw new Error('YOUTUBE_API_KEY not configured');
|
||||
}
|
||||
|
||||
let order = 'relevance';
|
||||
if (sort === 'date') order = 'date';
|
||||
else if (sort === 'views') order = 'viewCount';
|
||||
|
||||
const response = await fetch(
|
||||
`https://www.googleapis.com/youtube/v3/search?` +
|
||||
new URLSearchParams({
|
||||
@@ -30,7 +34,7 @@ const handler = {
|
||||
type: 'video',
|
||||
maxResults: Math.min(limit, 50).toString(),
|
||||
key: API_KEY,
|
||||
order: 'relevance'
|
||||
order
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user