import { c as defineEventHandler, r as readBody, e as createError } from '../../_/nitro.mjs';
import { a as activeProcesses } from '../../_/cli.mjs';
import treeKill from 'tree-kill';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'node:crypto';
import 'node:url';

const killScript_post = defineEventHandler(async (event) => {
  const body = await readBody(event);
  const process = activeProcesses[body.id];
  if (process) {
    treeKill(process.pid);
    delete activeProcesses[body.id];
  } else throw createError({ statusCode: 400, statusMessage: `Could not find script by id "${body.id}".` });
  return {};
});

export { killScript_post as default };
//# sourceMappingURL=kill-script.post.mjs.map
