import { i as defineEventHandler, K as readBody, e as createError, S as setSchedule } from '../../nitro/nitro.mjs';
import 'node:path';
import 'node:module';
import 'node:fs';
import 'node:os';
import 'dotenv';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:crypto';
import 'node:async_hooks';
import 'node:url';
import 'node:net';
import '@iconify/utils';
import 'consola';

const schedule_post = defineEventHandler(async (event) => {
  const body = await readBody(event);
  const cron = typeof (body == null ? void 0 : body.cron) === "string" ? body.cron.trim() : "";
  if (!cron) {
    throw createError({ statusCode: 400, statusMessage: "cron is required" });
  }
  const extraArgs = [];
  const envFile = typeof (body == null ? void 0 : body.envFile) === "string" ? body.envFile.trim() : "";
  if (envFile) extraArgs.push("-e", envFile);
  return setSchedule(cron, extraArgs);
});

export { schedule_post as default };
//# sourceMappingURL=schedule.post.mjs.map
