# All files / src/services discovery.ts

0% Statements 0/12
0% Branches 0/6
0% Functions 0/1
0% Lines 0/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29

     import { apiService } from './api';
    import { API_ENDPOINTS } from '@/constants';
    import type { ApiResult } from '@/types/api';
    import type { DiscoveryOverview } from '@/types/discovery';

    class DiscoveryService {
      async getOverview(params?: { language?: string; limit?: number }): Promise<ApiResult<DiscoveryOverview>> {
        const searchParams = new URLSearchParams();

        if (params?.language) {
          searchParams.set('language', params.language);
        }

        if (typeof params?.limit === 'number') {
          searchParams.set('limit', params.limit.toString());
        }

        const queryString = searchParams.toString();
        const url = queryString
          ? `${API_ENDPOINTS.DISCOVERY.OVERVIEW}?${queryString}`
          : API_ENDPOINTS.DISCOVERY.OVERVIEW;

        return apiService.get<DiscoveryOverview>(url);
      }
    }

    export const discoveryService = new DiscoveryService();
    export type { DiscoveryService };