fix: minor type changes for fonts

This commit is contained in:
Ilia Mashkov
2026-01-13 19:54:56 +03:00
parent 5fcb381b11
commit 4c9b9f631f
2 changed files with 21 additions and 11 deletions

View File

@@ -4,6 +4,10 @@
* Handles API requests to Google Fonts API for fetching font metadata.
* Provides error handling, retry logic, and type-safe responses.
*
* Pagination: The Google Fonts API does NOT support pagination parameters.
* All fonts matching the query are returned in a single response.
* Use category, subset, or sort filters to reduce the result set if needed.
*
* @see https://developers.google.com/fonts/docs/developer_api
*/
@@ -20,7 +24,7 @@ import type {
*/
export interface GoogleFontsParams extends QueryParams {
/**
* Google Fonts API key (optional for public endpoints)
* Google Fonts API key (required for Google Fonts API v1)
*/
key?: string;
/**
@@ -38,11 +42,11 @@ export interface GoogleFontsParams extends QueryParams {
/**
* Sort order for results
*/
sort?: 'popularity' | 'alpha' | 'date' | 'style';
sort?: 'alpha' | 'date' | 'popularity' | 'style' | 'trending';
/**
* Cap the number of fonts returned
*/
capability?: string;
capability?: 'VF' | 'WOFF2';
}
/**
@@ -59,8 +63,10 @@ export type GoogleFontItem = FontItem;
/**
* Google Fonts API base URL
* Note: Google Fonts API v1 requires an API key. For development/testing without a key,
* fonts may not load properly.
*/
const GOOGLE_FONTS_API_URL = 'https://fonts.googleapis.com/v2/fonts' as const;
const GOOGLE_FONTS_API_URL = 'https://www.googleapis.com/webfonts/v1/webfonts' as const;
/**
* Fetch fonts from Google Fonts API