23 lines
595 B
TypeScript
23 lines
595 B
TypeScript
import api from './client';
|
|
|
|
export interface ApiKey {
|
|
id: string;
|
|
name: string;
|
|
keyPrefix: string;
|
|
createdAt: string;
|
|
lastUsedAt: string | null;
|
|
expiresAt: string | null;
|
|
}
|
|
|
|
export interface CreatedApiKey {
|
|
plainKey: string;
|
|
entity: ApiKey;
|
|
}
|
|
|
|
export const apiKeysApi = {
|
|
getApiKeys: () => api.get<ApiKey[]>('/api/api-keys').then(r => r.data),
|
|
createApiKey: (name: string, expiresDays?: number) =>
|
|
api.post<CreatedApiKey>('/api/api-keys', { name, expiresDays }).then(r => r.data),
|
|
deleteApiKey: (id: string) => api.delete(`/api/api-keys/${id}`).then(r => r.data),
|
|
};
|