actionhero
Version:
actionhero.js is a multi-transport API Server with integrated cluster capabilities and delayed tasks
39 lines (38 loc) • 1.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Console = void 0;
const REPL = require("repl");
const index_1 = require("./../../index");
class Console extends index_1.CLI {
constructor() {
super();
this.name = "console";
this.description =
"start an interactive REPL session with the api object in-scope";
}
async run() {
for (const i in index_1.config.servers) {
index_1.config.servers[i].enabled = false;
}
index_1.config.general.developmentMode = false;
index_1.config.tasks.scheduler = false;
index_1.config.tasks.queues = [];
index_1.config.tasks.minTaskProcessors = 0;
index_1.config.tasks.maxTaskProcessors = 0;
await index_1.api.commands.start.call(index_1.api.process);
await index_1.utils.sleep(500);
await new Promise((resolve, reject) => {
const repl = REPL.start({
prompt: "[ AH::" + index_1.env + " ] >> ",
input: process.stdin,
output: process.stdout,
useGlobal: false,
});
repl.context.api = index_1.api;
repl.on("exit", resolve);
repl.on("error", reject);
});
return true;
}
}
exports.Console = Console;