# All files / src/api apiKeys.ts

0% Statements 0/12
0% Branches 0/6
0% Functions 0/5
0% Lines 0/10

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

     import { api } from './client';
    import type { ApiKeyItem, PaginatedList } from './types';

    export const apiKeyApi = {
      getList: (params?: { page?: number; pageSize?: number }) => {
        const qs = new URLSearchParams();
        if (params?.page) qs.set('page', String(params.page));
        if (params?.pageSize) qs.set('pageSize', String(params.pageSize));
        const query = qs.toString();
        return api.get<PaginatedList<ApiKeyItem>>(`/user/api-keys${query ? `?${query}` : ''}`);
      },
      create: (name: string) => api.post<ApiKeyItem>('/user/api-keys', { name }),
      delete: (id: number) => api.delete<null>(`/user/api-keys/${id}`),
      reset: (id: number) => api.post<ApiKeyItem>(`/user/api-keys/${id}/reset`),
      reveal: (id: number) => api.get<{ id: number; apiKey: string }>(`/user/api-keys/${id}/reveal`),
    };