56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
import axios from 'axios'
|
|
|
|
const api = axios.create({
|
|
baseURL: '/api',
|
|
timeout: 300000,
|
|
})
|
|
|
|
export interface Certificate {
|
|
id: number
|
|
domain: string
|
|
email: string
|
|
provider: string
|
|
challenge_type: string
|
|
dns_provider: string
|
|
dns_config: string
|
|
status: string
|
|
cert_url: string
|
|
expires_at: string | null
|
|
last_renewed_at: string | null
|
|
error_message: string
|
|
auto_renew: boolean
|
|
renew_days: number
|
|
created_at: string
|
|
updated_at: string
|
|
}
|
|
|
|
export interface Stats {
|
|
total: number
|
|
active: number
|
|
expired: number
|
|
errors: number
|
|
}
|
|
|
|
export interface CreateCertRequest {
|
|
domain: string
|
|
email: string
|
|
provider?: string
|
|
challenge_type?: string
|
|
dns_provider?: string
|
|
dns_config?: string
|
|
auto_renew?: boolean
|
|
renew_days?: number
|
|
}
|
|
|
|
export const certApi = {
|
|
list: () => api.get<Certificate[]>('/certificates'),
|
|
get: (id: number) => api.get<Certificate>(`/certificates/${id}`),
|
|
create: (data: CreateCertRequest) => api.post<Certificate>('/certificates', data),
|
|
update: (id: number, data: Partial<Certificate>) => api.put<Certificate>(`/certificates/${id}`, data),
|
|
delete: (id: number) => api.delete(`/certificates/${id}`),
|
|
renew: (id: number) => api.post(`/certificates/${id}/renew`),
|
|
files: (id: number) => api.get(`/certificates/${id}/files`),
|
|
checkRenewals: () => api.get('/renewals/check'),
|
|
stats: () => api.get<Stats>('/stats'),
|
|
}
|