mirror of https://github.com/certd/certd
chore:
parent
61b14b52d9
commit
17638f3d3a
|
@ -34,7 +34,8 @@
|
|||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"axios": "^1.7.7",
|
||||
"lodash-es": "^4.17.21"
|
||||
"lodash-es": "^4.17.21",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/**"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Config, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { AppKey, PlusRequestService, verify } from '@certd/plus-core';
|
||||
import { logger } from '@certd/basic';
|
||||
import { SysInstallInfo, SysLicenseInfo, SysSettingsService } from '../../settings/index.js';
|
||||
|
@ -8,15 +8,10 @@ import { SysInstallInfo, SysLicenseInfo, SysSettingsService } from '../../settin
|
|||
export class PlusService {
|
||||
@Inject()
|
||||
sysSettingsService: SysSettingsService;
|
||||
@Config('plus.server.baseUrls')
|
||||
plusServerBaseUrls: string[];
|
||||
|
||||
async getPlusRequestService() {
|
||||
const subjectId = await this.getSubjectId();
|
||||
return new PlusRequestService({
|
||||
plusServerBaseUrls: this.plusServerBaseUrls,
|
||||
subjectId,
|
||||
});
|
||||
return new PlusRequestService({ subjectId });
|
||||
}
|
||||
|
||||
async getSubjectId() {
|
||||
|
@ -60,26 +55,16 @@ export class PlusService {
|
|||
const licenseInfo: SysLicenseInfo = await this.sysSettingsService.getSetting(SysLicenseInfo);
|
||||
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
|
||||
|
||||
const plusRequestService = await this.getPlusRequestService();
|
||||
|
||||
return await verify({
|
||||
subjectId: plusRequestService.subjectId,
|
||||
subjectId: installInfo.siteId,
|
||||
license: licenseInfo.license,
|
||||
plusRequestService: plusRequestService,
|
||||
bindUrl: installInfo?.bindUrl,
|
||||
});
|
||||
}
|
||||
|
||||
async bindUrl(subjectId: string, url: string) {
|
||||
async bindUrl(url: string) {
|
||||
const plusRequestService = await this.getPlusRequestService();
|
||||
return await plusRequestService.request({
|
||||
url: '/activation/subject/urlBind',
|
||||
data: {
|
||||
subjectId,
|
||||
appKey: AppKey,
|
||||
url,
|
||||
},
|
||||
});
|
||||
return await plusRequestService.bindUrl(url);
|
||||
}
|
||||
|
||||
async register() {
|
||||
|
@ -88,16 +73,11 @@ export class PlusService {
|
|||
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
|
||||
if (!licenseInfo?.license) {
|
||||
//还没有license,注册一个
|
||||
const res = await plusRequestService.requestWithoutSign({
|
||||
url: '/activation/subject/register',
|
||||
data: {
|
||||
appKey: AppKey,
|
||||
subjectId: installInfo.siteId,
|
||||
const license = await plusRequestService.register({
|
||||
installTime: installInfo.installTime,
|
||||
},
|
||||
});
|
||||
if (res.license) {
|
||||
await this.updateLicense(res.license);
|
||||
if (license) {
|
||||
await this.updateLicense(license);
|
||||
logger.info('站点注册成功');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
# key: ./data/ssl/cert.key
|
||||
# cert: ./data/ssl/cert.crt
|
||||
#plus:
|
||||
# server:
|
||||
# baseUrl: 'http://127.0.0.1:11007'
|
||||
|
||||
#flyway:
|
||||
# scriptDir: './db/migration-pg'
|
||||
|
||||
#typeorm:
|
||||
# dataSource:
|
||||
# default:
|
||||
# type: postgres
|
||||
# host: localhost
|
||||
# port: 5433
|
||||
# username: postgres
|
||||
# password: root
|
||||
# database: postgres
|
||||
|
||||
typeorm:
|
||||
dataSource:
|
||||
default:
|
||||
database: './data/db-plus-dev.sqlite'
|
||||
|
||||
# plus server: 'http://127.0.0.1:11007'
|
||||
|
||||
account:
|
||||
server:
|
||||
baseUrl: 'http://127.0.0.1:1017/subject'
|
|
@ -10,6 +10,7 @@
|
|||
"commdev": "cross-env NODE_ENV=commdev mwtsc --watch --run @midwayjs/mock/app",
|
||||
"commpro": "cross-env NODE_ENV=commpro mwtsc --watch --run @midwayjs/mock/app",
|
||||
"pgdev": "cross-env NODE_ENV=pgdev mwtsc --watch --run @midwayjs/mock/app",
|
||||
"local-plus": "cross-env NODE_ENV=localplus mwtsc --watch --run @midwayjs/mock/app",
|
||||
"pgpl": "cross-env NODE_ENV=pgpl mwtsc --watch --run @midwayjs/mock/app",
|
||||
"dev-new": "cross-env NODE_ENV=devnew mwtsc --watch --run @midwayjs/mock/app",
|
||||
"rm-db-new": "rimraf ./data/db-new.sqlite",
|
||||
|
|
Loading…
Reference in New Issue