mirror of
https://github.com/certd/certd.git
synced 2026-08-01 10:27:35 +08:00
chore: format
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
import {Body, Controller, Get, Inject, Post, 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';
|
||||
import { Body, Controller, Get, Inject, Post, 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";
|
||||
|
||||
export function normalizeReleaseVersion(release: { tag_name?: string; name?: string }) {
|
||||
const version = release?.tag_name || release?.name || '';
|
||||
return version.replace(/^v/i, '');
|
||||
const version = release?.tag_name || release?.name || "";
|
||||
return version.replace(/^v/i, "");
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
@Provide()
|
||||
@Controller('/api/app/')
|
||||
@Controller("/api/app/")
|
||||
export class AppController extends BaseController {
|
||||
@Inject()
|
||||
sysSettingsService: SysSettingsService;
|
||||
@Inject()
|
||||
fileService: FileService;
|
||||
|
||||
@Get('/latest', { description: Constants.per.authOnly })
|
||||
@Get("/latest", { description: Constants.per.authOnly })
|
||||
async latest(): Promise<any> {
|
||||
try {
|
||||
const res = await http.request({
|
||||
url: 'https://api.atomgit.com/api/v5/repos/certd/certd/releases/latest',
|
||||
method: 'get',
|
||||
url: "https://api.atomgit.com/api/v5/repos/certd/certd/releases/latest",
|
||||
method: "get",
|
||||
logRes: false,
|
||||
timeout: 5000,
|
||||
});
|
||||
@@ -31,30 +31,30 @@ export class AppController extends BaseController {
|
||||
return this.ok(latest);
|
||||
} catch (e: any) {
|
||||
logger.error(e);
|
||||
return this.ok('');
|
||||
return this.ok("");
|
||||
}
|
||||
}
|
||||
|
||||
@Get('/favicon', { description: Constants.per.guest })
|
||||
@Get("/favicon", { description: 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;
|
||||
const redirect = "/api/basic/file/download?key=" + favicon;
|
||||
this.ctx.response.redirect(redirect);
|
||||
this.ctx.response.set('Cache-Control', 'public,max-age=25920');
|
||||
this.ctx.response.set("Cache-Control", "public,max-age=25920");
|
||||
return;
|
||||
}
|
||||
}
|
||||
const redirect = '/static/images/logo/logo.svg';
|
||||
const redirect = "/static/images/logo/logo.svg";
|
||||
this.ctx.response.redirect(redirect);
|
||||
this.ctx.response.set('Cache-Control', 'public,max-age=25920');
|
||||
this.ctx.response.set("Cache-Control", "public,max-age=25920");
|
||||
}
|
||||
|
||||
@Post('/webhook', { description: Constants.per.guest })
|
||||
public async webhook( @Body() body: any) {
|
||||
logger.info('webhook', JSON.stringify(body))
|
||||
return this.ok("success")
|
||||
@Post("/webhook", { description: Constants.per.guest })
|
||||
public async webhook(@Body() body: any) {
|
||||
logger.info("webhook", JSON.stringify(body));
|
||||
return this.ok("success");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user