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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 3x 28x 26x 6x 5x 4x 3x 5x | import { apiClient as api } from '@/lib/api';
export interface APIKeyListItem {
id: string;
name: string;
key: string; // Masked key
last_used_at: string | null;
expires_at: string | null;
is_active: boolean;
created_at: string;
}
export interface APIKeyListResponse {
items: APIKeyListItem[];
total: number;
}
export interface APIKeyCreateRequest {
name: string;
expires_at: string | null;
}
export interface APIKeyCreateResponse {
id: string;
name: string;
key: string; // Plaintext key (returned once)
expires_at: string | null;
created_at: string;
}
export interface APIKeyDetailResponse extends APIKeyListItem {
updated_at: string;
}
export const apiKeysService = {
getApiKeys: async (): Promise<APIKeyListResponse> => {
const response = await api.get<APIKeyListResponse>('/admin/api-keys');
return response.data;
},
createApiKey: async (data: APIKeyCreateRequest): Promise<APIKeyCreateResponse> => {
const response = await api.post<APIKeyCreateResponse>('/admin/api-keys', data);
return response.data;
},
getApiKeyById: async (id: string): Promise<APIKeyDetailResponse> => {
const response = await api.get<APIKeyDetailResponse>(`/admin/api-keys/${id}`);
return response.data;
},
revokeApiKey: async (id: string): Promise<void> => {
await api.delete(`/admin/api-keys/${id}`);
},
};
|