chore: format

This commit is contained in:
xiaojunnuo
2026-05-31 01:41:33 +08:00
parent acd440106b
commit 4b57a0d729
557 changed files with 12530 additions and 14039 deletions
@@ -1,18 +1,17 @@
import {http} from "@certd/basic";
import { http } from "@certd/basic";
import querystring from "querystring";
import {VolcengineOpts} from "./ve-client.js";
import { VolcengineOpts } from "./ve-client.js";
import { Pager, PageSearch } from "@certd/pipeline";
export type VolcengineReq = {
method?: string;
path?: string;
headers?: any;
body?: any;
query?: any;
service?: string, // 替换为实际服务名称
region?: string, // 替换为实际区域名称
}
service?: string; // 替换为实际服务名称
region?: string; // 替换为实际区域名称
};
export class VolcengineDnsClient {
opts: VolcengineOpts;
@@ -21,11 +20,10 @@ export class VolcengineDnsClient {
this.opts = opts;
}
async doRequest(req: VolcengineReq) {
const {Signer} =await import('@volcengine/openapi') ;
const { Signer } = await import("@volcengine/openapi");
// http request data
// http request data
const openApiRequestData: any = {
region: req.region,
method: req.method,
@@ -39,47 +37,42 @@ export class VolcengineDnsClient {
},
// [optional] http request body
body: req.body,
}
};
const signer = new Signer(openApiRequestData, req.service);
// sign
signer.addAuthorization({accessKeyId:this.opts.access.accessKeyId, secretKey:this.opts.access.secretAccessKey});
// sign
signer.addAuthorization({ accessKeyId: this.opts.access.accessKeyId, secretKey: this.opts.access.secretAccessKey });
// Print signed headers
// Print signed headers
console.log(openApiRequestData.headers);
const url = `https://open.volcengineapi.com/?${querystring.stringify(req.query)}`;
const url = `https://open.volcengineapi.com/?${querystring.stringify(req.query)}`
try{
try {
const res = await http.request({
url: url,
method: req.method,
headers: openApiRequestData.headers,
data:req.body
data: req.body,
});
if (res?.ResponseMetadata?.Error) {
const err = new Error(JSON.stringify(res.ResponseMetadata.Error));
// @ts-ignore
err.detail = res.ResponseMetadata.Error;
throw err
throw err;
}
return res
}catch (e) {
if(e.response){
return res;
} catch (e) {
if (e.response) {
const err = new Error(JSON.stringify(e.response.data.ResponseMetadata.Error));
// @ts-ignore
err.detail = e.response.data.ResponseMetadata.Error;
throw err
throw err;
}
}
}
async findDomain(domain: string) {
const req: VolcengineReq = {
method: "POST",
@@ -89,24 +82,24 @@ export class VolcengineDnsClient {
Action: "ListZones",
Version: "2018-08-01",
},
body:{
body: {
Key: domain,
SearchMode: "exact"
}
SearchMode: "exact",
},
};
return this.doRequest(req);
}
async getDomainList(page: PageSearch) {
const pager = new Pager(page)
const body:any = {
SearchMode: "like",
PageNumber: pager.pageNo,
PageSize: pager.pageSize,
}
async getDomainList(page: PageSearch) {
const pager = new Pager(page);
const body: any = {
SearchMode: "like",
PageNumber: pager.pageNo,
PageSize: pager.pageSize,
};
if (page.searchKey) {
body.Key = page.searchKey
body.Key = page.searchKey;
}
const req: VolcengineReq = {
method: "POST",
@@ -116,22 +109,21 @@ export class VolcengineDnsClient {
Action: "ListZones",
Version: "2018-08-01",
},
body:body
body: body,
};
const res = await this.doRequest(req);
let list = res.Result?.Zones || []
list = list.map((item:any) => {
let list = res.Result?.Zones || [];
list = list.map((item: any) => {
return {
id: item.ZID,
domain: item.ZoneName,
}
})
const total = res.Result?.Total|| list.length
};
});
const total = res.Result?.Total || list.length;
return {
list,
total
}
total,
};
}
}