mirror of
https://github.com/certd/certd.git
synced 2026-04-25 05:07:25 +08:00
chore: safePromise 优化
This commit is contained in:
@@ -2,7 +2,7 @@ import https from 'node:https';
|
||||
import fs from 'fs';
|
||||
import { Application } from '@midwayjs/koa';
|
||||
import { createSelfCertificate } from './self-certificate.js';
|
||||
import { logger } from '@certd/basic';
|
||||
import {logger, safePromise} from '@certd/basic';
|
||||
|
||||
export type HttpsServerOptions = {
|
||||
enabled: boolean;
|
||||
@@ -23,7 +23,7 @@ export class HttpsServer {
|
||||
}
|
||||
|
||||
async close() {
|
||||
return new Promise((resolve, reject) => {
|
||||
return safePromise((resolve, reject) => {
|
||||
this.server.close(() => {
|
||||
resolve(true);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { logger, utils } from '@certd/basic';
|
||||
import {logger, safePromise, utils} from '@certd/basic';
|
||||
import { merge } from 'lodash-es';
|
||||
import https from 'https';
|
||||
import { PeerCertificate } from 'tls';
|
||||
@@ -49,7 +49,7 @@ export class SiteTester {
|
||||
);
|
||||
options.agent = agent;
|
||||
// 创建 HTTPS 请求
|
||||
const requestPromise = new Promise((resolve, reject) => {
|
||||
const requestPromise = safePromise((resolve, reject) => {
|
||||
const req = https.request(options, res => {
|
||||
// 获取证书
|
||||
// @ts-ignore
|
||||
|
||||
Reference in New Issue
Block a user