This commit is contained in:
xiaojunnuo
2025-01-19 01:07:20 +08:00
parent 5fc07d4dd4
commit 7f6d03c02a
9 changed files with 9 additions and 8 deletions
@@ -0,0 +1,48 @@
import { Controller, Get, Inject, Provide } from '@midwayjs/core';
import { BaseController, Constants, FileService, SysSettingsService, SysSiteInfo } from '@certd/lib-server';
import { http, logger } from '@certd/basic';
import { isComm } from '@certd/plus-core';
/**
*/
@Provide()
@Controller('/api/app/')
export class AppController extends BaseController {
@Inject()
sysSettingsService: SysSettingsService;
@Inject()
fileService: FileService;
@Get('/latest', { summary: Constants.per.authOnly })
async latest(): Promise<any> {
const res = await http.request({
url: 'https://registry.npmmirror.com/@certd/pipeline',
method: 'get',
logRes: false,
});
try {
const latest = res['dist-tags'].latest;
return this.ok(latest);
} catch (e: any) {
logger.error(e);
return this.ok('');
}
}
@Get('/favicon', { summary: Constants.per.guest })
public async getFavicon() {
if (isComm()) {
const siteInfo = await this.sysSettingsService.getSetting<SysSiteInfo>(SysSiteInfo);
const favicon = siteInfo.logo;
if (favicon) {
const redirect = '/api/basic/file/download?key=' + favicon;
this.ctx.response.redirect(redirect);
this.ctx.response.set('Cache-Control', 'public,max-age=25920');
return;
}
}
const redirect = '/static/images/logo/logo.svg';
this.ctx.response.redirect(redirect);
this.ctx.response.set('Cache-Control', 'public,max-age=25920');
}
}