Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit a46e6fc

Browse files
committed
refactor: instance update config api
1 parent 2e15f2f commit a46e6fc

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/common/typecheck.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,28 @@ export function configureEntityParams(self: any, args: any, key: string, typeFn?
4444
self[key] = v;
4545
}
4646
}
47+
48+
export function toText(v: any) {
49+
if (isEmpty(v)) return null;
50+
return String(v);
51+
}
52+
53+
export function toNumber(v: any) {
54+
if (isEmpty(v)) return null;
55+
if (isNaN(Number(v))) return null;
56+
return Number(v);
57+
}
58+
59+
export function toBoolean(v: any) {
60+
if (isEmpty(v)) return null;
61+
return Boolean(v);
62+
}
63+
64+
export function isEmpty(v: any) {
65+
return v === null || v === undefined;
66+
}
67+
68+
export function supposeValue(v: any, def: any = null) {
69+
if (isEmpty(v)) return def;
70+
return v;
71+
}

src/entity/commands/task/openfrp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default class OpenFrpTask implements ILifeCycleTask {
4444
public name: string = "openfrp";
4545

4646
async start(instance: Instance) {
47-
const { openFrpToken, openFrpTunnelId, isOpenFrp } = instance.config?.extraServiceConfig;
47+
const { openFrpToken, openFrpTunnelId } = instance.config?.extraServiceConfig;
4848
if (openFrpToken && openFrpTunnelId) {
4949
const frpProcess = new OpenFrp(openFrpToken, openFrpTunnelId);
5050
frpProcess.processWrapper.on("start", (pid) => {

src/entity/instance/Instance_config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export default class InstanceConfig {
6767
};
6868

6969
public extraServiceConfig = {
70-
isOpenFrp: false,
7170
openFrpTunnelId: "",
7271
openFrpToken: ""
7372
};

0 commit comments

Comments
 (0)