feat: add common service available check

pull/90/head
moonrailgun 2 years ago
parent 1fa1293d1a
commit 0cb61bcf85

@ -313,6 +313,16 @@ export abstract class TcService extends Service {
});
}
/**
* action
*
* ,
*/
registerAvailableAction(checkFn: () => boolean) {
this.registerAction('available', checkFn);
this.registerAuthWhitelist(['/available']);
}
/**
*
* @param panelFeature

@ -76,13 +76,26 @@ class AgoraService extends TcService {
return process.env.AGORA_CUSTOMER_SECRET;
}
onInit() {
/**
*
*/
get serverAvailable(): boolean {
if (
!this.serverAppId ||
!this.serverAppCertificate ||
!this.serverCustomerKey ||
!this.serverCustomerSecret
this.serverAppId &&
this.serverAppCertificate &&
this.serverCustomerKey &&
this.serverCustomerSecret
) {
return true;
}
return false;
}
onInit() {
this.registerAvailableAction(() => this.serverAvailable);
if (!this.serverAvailable) {
console.warn(
'声网服务启动失败, 缺少必要的环境变量: AGORA_APP_ID, AGORA_APP_CERT, AGORA_CUSTOMER_KEY, AGORA_CUSTOMER_SECRET'
);

@ -32,6 +32,8 @@ class GetuiService extends TcService {
}
onInit() {
this.registerAvailableAction(() => this.getuiAvailable);
if (!this.getuiAvailable) {
console.warn(
'[plugin:com.msgbyte.getui] require env: GETUI_APPID, GETUI_APPKEY, GETUI_MASTERSECRET'

@ -20,7 +20,7 @@ class MeetingService extends TcService {
onInit() {
// this.registerLocalDb(require('../models/meeting').default);
this.registerAction('available', this.available);
this.registerAvailableAction(() => Boolean(this.tailchatMeetingUrl));
if (!isValidStr(this.tailchatMeetingUrl)) {
return;
@ -41,10 +41,6 @@ class MeetingService extends TcService {
);
}
available(ctx: TcContext) {
return Boolean(this.tailchatMeetingUrl);
}
/**
*
*/

Loading…
Cancel
Save