mirror of
https://github.com/louislam/dockge.git
synced 2024-11-30 14:24:02 +00:00
31 lines
768 B
TypeScript
31 lines
768 B
TypeScript
import { BeanModel } from "redbean-node/dist/bean-model";
|
|
import { R } from "redbean-node";
|
|
import { LooseObject } from "../../common/util-common";
|
|
|
|
export class Agent extends BeanModel {
|
|
|
|
static async getAgentList() : Promise<Record<string, Agent>> {
|
|
let list = await R.findAll("agent") as Agent[];
|
|
let result : Record<string, Agent> = {};
|
|
for (let agent of list) {
|
|
result[agent.endpoint] = agent;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
get endpoint() : string {
|
|
let obj = new URL(this.url);
|
|
return obj.host;
|
|
}
|
|
|
|
toJSON() : LooseObject {
|
|
return {
|
|
url: this.url,
|
|
username: this.username,
|
|
endpoint: this.endpoint,
|
|
};
|
|
}
|
|
|
|
}
|
|
|
|
export default Agent;
|