2024-10-26 16:36:57 +08:00
|
|
|
import { App, Autoload, Config, Init, Inject, Scope, ScopeEnum } from '@midwayjs/core';
|
2024-11-04 16:39:02 +08:00
|
|
|
import { getPlusInfo, isPlus } from '@certd/plus-core';
|
|
|
|
|
import { logger } from '@certd/basic';
|
|
|
|
|
|
2024-10-14 10:57:12 +08:00
|
|
|
import { SysInstallInfo, SysSettingsService } from '@certd/lib-server';
|
|
|
|
|
import { getVersion } from '../../utils/version.js';
|
2024-10-14 11:41:34 +08:00
|
|
|
import dayjs from 'dayjs';
|
2024-10-26 16:36:57 +08:00
|
|
|
import { Application } from '@midwayjs/koa';
|
2024-10-26 18:01:06 +08:00
|
|
|
import { httpsServer, HttpsServerOptions } from './https/server.js';
|
2024-10-14 10:57:12 +08:00
|
|
|
|
|
|
|
|
@Autoload()
|
2024-12-23 00:24:31 +08:00
|
|
|
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
2024-10-14 10:57:12 +08:00
|
|
|
export class AutoZPrint {
|
|
|
|
|
@Inject()
|
|
|
|
|
sysSettingsService: SysSettingsService;
|
|
|
|
|
|
2024-10-26 16:36:57 +08:00
|
|
|
@App()
|
|
|
|
|
app: Application;
|
|
|
|
|
|
|
|
|
|
@Config('https')
|
|
|
|
|
httpsConfig: HttpsServerOptions;
|
|
|
|
|
|
2024-10-14 10:57:12 +08:00
|
|
|
@Init()
|
|
|
|
|
async init() {
|
2024-10-26 16:36:57 +08:00
|
|
|
//监听https
|
|
|
|
|
this.startHttpsServer();
|
|
|
|
|
|
2024-10-14 10:57:12 +08:00
|
|
|
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
|
|
|
|
|
logger.info('=========================================');
|
|
|
|
|
logger.info('当前站点ID:', installInfo.siteId);
|
|
|
|
|
const version = await getVersion();
|
|
|
|
|
logger.info(`当前版本:${version}`);
|
2024-10-14 11:41:34 +08:00
|
|
|
const plusInfo = getPlusInfo();
|
|
|
|
|
if (isPlus()) {
|
|
|
|
|
logger.info(`授权信息:${plusInfo.vipType},${dayjs(plusInfo.expireTime).format('YYYY-MM-DD')}`);
|
|
|
|
|
}
|
2024-10-14 11:52:37 +08:00
|
|
|
logger.info('Certd已启动');
|
2024-10-14 10:57:12 +08:00
|
|
|
logger.info('=========================================');
|
|
|
|
|
}
|
2024-10-26 16:36:57 +08:00
|
|
|
|
|
|
|
|
async startHttpsServer() {
|
|
|
|
|
if (!this.httpsConfig.enabled) {
|
|
|
|
|
logger.info('Https server is not enabled');
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-10-26 18:01:06 +08:00
|
|
|
httpsServer.start({
|
2024-10-26 16:36:57 +08:00
|
|
|
...this.httpsConfig,
|
|
|
|
|
app: this.app,
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-10-14 10:57:12 +08:00
|
|
|
}
|