import { logger } from "../common/logger.js";
import { ApiServer } from "./server/server.js";
export async function editor(argv) {
    const workingDir = argv.dir || process.cwd();
    const server = new ApiServer({
        cliArgs: argv,
        workingDir,
        port: argv.port,
        isStandalone: true,
    });
    server.start().catch((err) => logger.error(err));
    return new Promise((resolve) => {
        process.on("SIGTERM", async () => {
            await server.close();
            resolve();
        });
        process.on("SIGINT", async () => {
            await server.close();
            resolve();
        });
    });
}
//# sourceMappingURL=handler.js.map