import { c as defineEventHandler, g as getQuery } from '../../../_/nitro.mjs';
import netstat from 'node-netstat';
import findProcess from 'find-process';
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 netstatAsync = (opts) => new Promise((resolve, reject) => {
  const res = [];
  netstat(
    {
      ...opts,
      done: (err) => {
        if (err) return reject(err);
        return resolve(res);
      }
    },
    (data) => {
      res.push(data);
    }
  );
  return res;
});
const getProcess_get = defineEventHandler(async (event) => {
  const processId = parseInt(getQuery(event).process);
  const stats = {
    netstat: await netstatAsync({
      filter: {
        pid: processId
      }
    }),
    processStats: await findProcess("pid", processId).then((e) => e[0])
  };
  return stats;
});

export { getProcess_get as default };
//# sourceMappingURL=get-process.get.mjs.map
