actionhero
Version:
The reusable, scalable, and quick node.js API server for stateless and stateful applications
30 lines (24 loc) • 633 B
text/typescript
import * as REPL from "repl";
import { api, env, CLI } from "./../../index";
export class Console extends CLI {
constructor() {
super();
this.name = "console";
this.description =
"Start an interactive REPL session with the api object in-scope";
}
async run() {
await new Promise((resolve, reject) => {
const repl = REPL.start({
prompt: "[ AH::" + env + " ] >> ",
input: process.stdin,
output: process.stdout,
useGlobal: false,
});
repl.context.api = api;
repl.on("exit", resolve);
repl.on("error", reject);
});
return true;
}
}