Skip to content

Commit

Permalink
fix: error
Browse files Browse the repository at this point in the history
  • Loading branch information
5aaee9 committed Jan 7, 2023
1 parent bf2ae49 commit 3011c99
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
37 changes: 22 additions & 15 deletions src/api/cert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import { objectToCamelCase, objectToHungarian } from '@/utils/case'
import { APIResponse } from '.'


export type CertificateAuthority = 'digicert' | 'google' | 'lets_encrypt' | 'sectigo'
export type CertificateAuthority = 'digicert' | 'google' | 'lets_encrypt'

export const CertificateAuthorityDisplay : Record<CertificateAuthority, string> = {
digicert: 'DigiCert',
google: 'Google',
lets_encrypt: 'Let\'s Encrypt',
sectigo: 'Sectigo'
}

export type CloudflareCertInfo = {
Expand All @@ -19,24 +18,32 @@ export type CloudflareCertInfo = {
export async function getCertInfo(zoneId: string): Promise<APIResponse<CloudflareCertInfo>> {
const axios = useAxios()

const response = await axios.request<any>({
url: `/zones/${zoneId}/ssl/universal/settings`,
method: 'get',
})
try {
const response = await axios.request<any>({
url: `/zones/${zoneId}/ssl/universal/settings`,
method: 'get',
})

return (objectToCamelCase(response.data) as any)
return (objectToCamelCase(response.data) as any)
} catch (err) {
return (objectToCamelCase(err.response.data) as any)
}
}

export async function patchCertAuthority(zoneId: string, authority: CertificateAuthority): Promise<APIResponse<any>> {
const axios = useAxios()

const response = await axios.request<any>({
url: `/zones/${zoneId}/ssl/universal/settings`,
method: 'patch',
data: objectToHungarian({
certificateAuthority: authority,
try {

const response = await axios.request<any>({
url: `/zones/${zoneId}/ssl/universal/settings`,
method: 'patch',
data: objectToHungarian({
certificateAuthority: authority,
})
})
})

return (objectToCamelCase(response.data) as any)
return (objectToCamelCase(response.data) as any)
} catch (err) {
return (objectToCamelCase(err.response.data) as any)
}
}
6 changes: 3 additions & 3 deletions src/route/zone/CertInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ const newCertOwner = ref<CertificateAuthority>('lets_encrypt')
async function loadInfo() {
isLoading.value = true
try {
const info = await getCertInfo(props.zoneId)
const info = await getCertInfo(props.zoneId)
if (info.success) {
certOwner.value = info.result!.certificateAuthority
newCertOwner.value = info.result!.certificateAuthority
} catch (err) {
} else {
mainStyle.value = {
display: 'hidden'
}
Expand Down

0 comments on commit 3011c99

Please sign in to comment.