mirror of
https://github.com/certd/certd.git
synced 2026-05-16 05:07:32 +08:00
feat: 升级midway,支持esm
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Autoload, Init, Inject, Scope, ScopeEnum } from '@midwayjs/decorator';
|
||||
import { PipelineService } from '../service/pipeline-service';
|
||||
import { logger } from '../../../utils/logger';
|
||||
import { Autoload, Init, Inject, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { PipelineService } from '../service/pipeline-service.js';
|
||||
import { logger } from '../../../utils/logger.js';
|
||||
|
||||
@Autoload()
|
||||
@Scope(ScopeEnum.Singleton)
|
||||
|
||||
@@ -6,10 +6,10 @@ import {
|
||||
Post,
|
||||
Provide,
|
||||
Query,
|
||||
} from '@midwayjs/decorator';
|
||||
import { CrudController } from '../../../basic/crud-controller';
|
||||
import { AccessService } from '../service/access-service';
|
||||
import { Constants } from '../../../basic/constants';
|
||||
} from '@midwayjs/core';
|
||||
import { CrudController } from '../../../basic/crud-controller.js';
|
||||
import { AccessService } from '../service/access-service.js';
|
||||
import { Constants } from '../../../basic/constants.js';
|
||||
|
||||
/**
|
||||
* 授权
|
||||
|
||||
+4
-11
@@ -1,14 +1,7 @@
|
||||
import {
|
||||
ALL,
|
||||
Controller,
|
||||
Inject,
|
||||
Post,
|
||||
Provide,
|
||||
Query,
|
||||
} from '@midwayjs/decorator';
|
||||
import { DnsProviderService } from '../service/dns-provider-service';
|
||||
import { BaseController } from '../../../basic/base-controller';
|
||||
import {Constants} from "../../../basic/constants";
|
||||
import { ALL, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { DnsProviderService } from '../service/dns-provider-service.js';
|
||||
import { BaseController } from '../../../basic/base-controller.js';
|
||||
import { Constants } from '../../../basic/constants.js';
|
||||
|
||||
/**
|
||||
* 插件
|
||||
|
||||
@@ -1,25 +1,16 @@
|
||||
import {
|
||||
ALL,
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Inject,
|
||||
Post,
|
||||
Provide,
|
||||
Query,
|
||||
} from '@midwayjs/decorator';
|
||||
import { CrudController } from '../../../basic/crud-controller';
|
||||
import { PipelineEntity } from '../entity/pipeline';
|
||||
import { HistoryService } from '../service/history-service';
|
||||
import { HistoryLogService } from '../service/history-log-service';
|
||||
import { HistoryEntity } from '../entity/history';
|
||||
import { HistoryLogEntity } from '../entity/history-log';
|
||||
import { Constants } from '../../../basic/constants';
|
||||
import { PipelineService } from '../service/pipeline-service';
|
||||
import { CommonException } from '../../../basic/exception/common-exception';
|
||||
import { PermissionException } from '../../../basic/exception/permission-exception';
|
||||
import { ALL, Body, Controller, Get, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { CrudController } from '../../../basic/crud-controller.js';
|
||||
import { PipelineEntity } from '../entity/pipeline.js';
|
||||
import { HistoryService } from '../service/history-service.js';
|
||||
import { HistoryLogService } from '../service/history-log-service.js';
|
||||
import { HistoryEntity } from '../entity/history.js';
|
||||
import { HistoryLogEntity } from '../entity/history-log.js';
|
||||
import { Constants } from '../../../basic/constants.js';
|
||||
import { PipelineService } from '../service/pipeline-service.js';
|
||||
import { CommonException } from '../../../basic/exception/common-exception.js';
|
||||
import { PermissionException } from '../../../basic/exception/permission-exception.js';
|
||||
import * as fs from 'fs';
|
||||
import { logger } from '../../../utils/logger';
|
||||
import { logger } from '../../../utils/logger.js';
|
||||
|
||||
/**
|
||||
* 证书
|
||||
@@ -53,11 +44,7 @@ export class HistoryController extends CrudController<HistoryService> {
|
||||
const buildQuery = qb => {
|
||||
qb.limit(10);
|
||||
};
|
||||
const listRet = await this.getService().list(
|
||||
body,
|
||||
{ prop: 'id', asc: false },
|
||||
buildQuery
|
||||
);
|
||||
const listRet = await this.getService().list(body, { prop: 'id', asc: false }, buildQuery);
|
||||
return this.ok(listRet);
|
||||
}
|
||||
|
||||
@@ -137,11 +124,7 @@ export class HistoryController extends CrudController<HistoryService> {
|
||||
}
|
||||
|
||||
@Get('/download', { summary: Constants.per.authOnly })
|
||||
async download(
|
||||
@Query('pipelineId') pipelineId,
|
||||
@Query('historyId') historyId,
|
||||
@Query('fileId') fileId
|
||||
) {
|
||||
async download(@Query('pipelineId') pipelineId, @Query('historyId') historyId, @Query('fileId') fileId) {
|
||||
const files = await this.getFiles(historyId, pipelineId);
|
||||
const file = files.find(f => f.id === fileId);
|
||||
if (file == null) {
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
import {
|
||||
ALL,
|
||||
Body,
|
||||
Controller,
|
||||
Inject,
|
||||
Post,
|
||||
Provide,
|
||||
Query,
|
||||
} from '@midwayjs/decorator';
|
||||
import { CrudController } from '../../../basic/crud-controller';
|
||||
import { PipelineService } from '../service/pipeline-service';
|
||||
import { PipelineEntity } from '../entity/pipeline';
|
||||
import { Constants } from '../../../basic/constants';
|
||||
import { HistoryService } from '../service/history-service';
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { CrudController } from '../../../basic/crud-controller.js';
|
||||
import { PipelineService } from '../service/pipeline-service.js';
|
||||
import { PipelineEntity } from '../entity/pipeline.js';
|
||||
import { Constants } from '../../../basic/constants.js';
|
||||
import { HistoryService } from '../service/history-service.js';
|
||||
|
||||
/**
|
||||
* 证书
|
||||
|
||||
@@ -5,10 +5,10 @@ import {
|
||||
Post,
|
||||
Provide,
|
||||
Query,
|
||||
} from '@midwayjs/decorator';
|
||||
import { BaseController } from '../../../basic/base-controller';
|
||||
import { PluginService } from '../service/plugin-service';
|
||||
import { Constants } from '../../../basic/constants';
|
||||
} from '@midwayjs/core';
|
||||
import { BaseController } from '../../../basic/base-controller.js';
|
||||
import { PluginService } from '../service/plugin-service.js';
|
||||
import { Constants } from '../../../basic/constants.js';
|
||||
|
||||
/**
|
||||
* 插件
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HistoryEntity } from '../history';
|
||||
import { HistoryLogEntity } from '../history-log';
|
||||
import { HistoryEntity } from '../history.js';
|
||||
import { HistoryLogEntity } from '../history-log.js';
|
||||
|
||||
export class HistoryDetail {
|
||||
history: HistoryEntity;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { PipelineEntity } from '../pipeline';
|
||||
import { HistoryEntity } from '../history';
|
||||
import { HistoryLogEntity } from '../history-log';
|
||||
import { PipelineEntity } from '../pipeline.js';
|
||||
import { HistoryEntity } from '../history.js';
|
||||
import { HistoryLogEntity } from '../history-log.js';
|
||||
|
||||
export class PipelineDetail {
|
||||
pipeline: PipelineEntity;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/decorator';
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService } from '../../../basic/base-service';
|
||||
import { AccessEntity } from '../entity/access';
|
||||
import { BaseService } from '../../../basic/base-service.js';
|
||||
import { AccessEntity } from '../entity/access.js';
|
||||
import { accessRegistry, IAccessService } from '@certd/pipeline';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { IStorage } from '@certd/pipeline';
|
||||
import { StorageService } from './storage-service';
|
||||
import { StorageService } from './storage-service.js';
|
||||
|
||||
export class DbStorage implements IStorage {
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/decorator';
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { dnsProviderRegistry } from '@certd/plugin-cert';
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Singleton)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Provide, Scope, ScopeEnum } from "@midwayjs/decorator";
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService } from '../../../basic/base-service';
|
||||
import { HistoryLogEntity } from '../entity/history-log';
|
||||
import { BaseService } from '../../../basic/base-service.js';
|
||||
import { HistoryLogEntity } from '../entity/history-log.js';
|
||||
|
||||
/**
|
||||
* 证书申请
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { Config, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/decorator';
|
||||
import { Config, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService } from '../../../basic/base-service';
|
||||
import { HistoryEntity } from '../entity/history';
|
||||
import { PipelineEntity } from '../entity/pipeline';
|
||||
import { HistoryDetail } from '../entity/vo/history-detail';
|
||||
import { HistoryLogService } from './history-log-service';
|
||||
import { BaseService } from '../../../basic/base-service.js';
|
||||
import { HistoryEntity } from '../entity/history.js';
|
||||
import { PipelineEntity } from '../entity/pipeline.js';
|
||||
import { HistoryDetail } from '../entity/vo/history-detail.js';
|
||||
import { HistoryLogService } from './history-log-service.js';
|
||||
import { FileItem, Pipeline, RunnableCollection } from '@certd/pipeline';
|
||||
import { FileStore } from '@certd/pipeline';
|
||||
import { logger } from '../../../utils/logger';
|
||||
import { logger } from '../../../utils/logger.js';
|
||||
|
||||
/**
|
||||
* 证书申请
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import { Config, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/decorator';
|
||||
import { Config, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||
import { In, Repository } from 'typeorm';
|
||||
import { BaseService } from '../../../basic/base-service';
|
||||
import { PipelineEntity } from '../entity/pipeline';
|
||||
import { PipelineDetail } from '../entity/vo/pipeline-detail';
|
||||
import { BaseService } from '../../../basic/base-service.js';
|
||||
import { PipelineEntity } from '../entity/pipeline.js';
|
||||
import { PipelineDetail } from '../entity/vo/pipeline-detail.js';
|
||||
import { Executor, Pipeline, ResultType, RunHistory } from '@certd/pipeline';
|
||||
import { AccessService } from './access-service';
|
||||
import { DbStorage } from './db-storage';
|
||||
import { StorageService } from './storage-service';
|
||||
import { Cron } from '../../plugin/cron/cron';
|
||||
import { HistoryService } from './history-service';
|
||||
import { HistoryEntity } from '../entity/history';
|
||||
import { HistoryLogEntity } from '../entity/history-log';
|
||||
import { HistoryLogService } from './history-log-service';
|
||||
import { logger } from '../../../utils/logger';
|
||||
import { EmailService } from '../../basic/service/email-service';
|
||||
import { AccessService } from './access-service.js';
|
||||
import { DbStorage } from './db-storage.js';
|
||||
import { StorageService } from './storage-service.js';
|
||||
import { Cron } from '../../plugin/cron/cron.js';
|
||||
import { HistoryService } from './history-service.js';
|
||||
import { HistoryEntity } from '../entity/history.js';
|
||||
import { HistoryLogEntity } from '../entity/history-log.js';
|
||||
import { HistoryLogService } from './history-log-service.js';
|
||||
import { logger } from '../../../utils/logger.js';
|
||||
import { EmailService } from '../../basic/service/email-service.js';
|
||||
|
||||
const runningTasks: Map<string | number, Executor> = new Map();
|
||||
|
||||
@@ -138,7 +138,11 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
cron: null,
|
||||
job: async () => {
|
||||
logger.info('job准备启动,当前定时器数量:', this.cron.getListSize());
|
||||
await this.run(id, null);
|
||||
try {
|
||||
await this.run(id, null);
|
||||
} catch (e) {
|
||||
logger.error('定时job执行失败:', e);
|
||||
}
|
||||
},
|
||||
});
|
||||
logger.info('定时器数量:', this.cron.getListSize());
|
||||
@@ -230,7 +234,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
await executor.run(historyId, triggerType);
|
||||
} catch (e) {
|
||||
logger.error('执行失败:', e);
|
||||
throw e;
|
||||
// throw e;
|
||||
} finally {
|
||||
runningTasks.delete(historyId);
|
||||
}
|
||||
@@ -242,8 +246,8 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
await executor.cancel();
|
||||
} else {
|
||||
const entity = await this.historyService.info(historyId);
|
||||
if(entity == null){
|
||||
return
|
||||
if (entity == null) {
|
||||
return;
|
||||
}
|
||||
const pipeline: Pipeline = JSON.parse(entity.pipeline);
|
||||
pipeline.status.status = ResultType.canceled;
|
||||
@@ -295,7 +299,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
const entity: HistoryEntity = new HistoryEntity();
|
||||
entity.id = parseInt(history.id);
|
||||
entity.userId = history.pipeline.userId;
|
||||
entity.status = pipelineEntity.status
|
||||
entity.status = pipelineEntity.status;
|
||||
entity.pipeline = JSON.stringify(history.pipeline);
|
||||
entity.pipelineId = parseInt(history.pipeline.id);
|
||||
await this.historyService.save(entity);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Provide, Scope, ScopeEnum } from "@midwayjs/decorator";
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { pluginRegistry } from '@certd/pipeline';
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Singleton)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/decorator';
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService } from '../../../basic/base-service';
|
||||
import { StorageEntity } from '../entity/storage';
|
||||
import { BaseService } from '../../../basic/base-service.js';
|
||||
import { StorageEntity } from '../entity/storage.js';
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user