cn-shell
Version:
Cloud Native Shell
80 lines (79 loc) • 1.93 kB
JavaScript
const DEFAULT_CONFIG_OPTIONS = {
envVarPrefix: "CNE_",
};
export class ShellExt {
_name;
_shell;
constructor(config) {
this._name = config.name;
this._shell = config.shell;
this._shell.addExt(this);
this.startup("Initialising ...");
}
async start() {
this.startup("Started!");
return true;
}
async stop() {
this.startup("Stopped!");
return;
}
async healthCheck() {
this.debug("Health check called");
return true;
}
get name() {
return this._name;
}
getConfigStr(config, passedOptions = {}) {
let options = {
...DEFAULT_CONFIG_OPTIONS,
...passedOptions,
};
return this._shell.getConfigStr(config, options, this._name);
}
getConfigBool(config, passedOptions = {}) {
let options = {
...DEFAULT_CONFIG_OPTIONS,
...passedOptions,
};
return this._shell.getConfigBool(config, options, this._name);
}
getConfigNum(config, passedOptions = {}) {
let options = {
...DEFAULT_CONFIG_OPTIONS,
...passedOptions,
};
return this._shell.getConfigNum(config, options, this._name);
}
fatal(...args) {
this._shell.logger.fatal(this._name, ...args);
}
error(...args) {
this._shell.logger.error(this._name, ...args);
}
warn(...args) {
this._shell.logger.warn(this._name, ...args);
}
info(...args) {
this._shell.logger.info(this._name, ...args);
}
startup(...args) {
this._shell.logger.startup(this._name, ...args);
}
debug(...args) {
this._shell.logger.debug(this._name, ...args);
}
trace(...args) {
this._shell.logger.trace(this._name, ...args);
}
force(...args) {
this._shell.logger.force(this._name, ...args);
}
createHttpReqPool(origin, passedOptions) {
this._shell.createHttpReqPool(origin, passedOptions);
}
async httpReq(origin, path, passedOptions) {
return this._shell.httpReq(origin, path, passedOptions);
}
}