import { i as defineEventHandler, y as getRouterParam, e as createError, K as readBody, t as getProvider } 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 comment_post = defineEventHandler(async (event) => {
  var _a;
  const id = getRouterParam(event, "id");
  if (!id) {
    throw createError({ statusCode: 400, statusMessage: "Missing task id" });
  }
  const body = (_a = await readBody(event)) != null ? _a : {};
  const text = typeof body.text === "string" ? body.text.trim() : "";
  if (!text) {
    throw createError({ statusCode: 400, statusMessage: "Body must include non-empty `text`" });
  }
  const { config, provider } = getProvider(event);
  const finalText = body.asAidev && config.commentPrefix ? `${config.commentPrefix} ${text}` : text;
  await provider.postComment(id, finalText);
  return { ok: true, id, text: finalText };
});

export { comment_post as default };
//# sourceMappingURL=comment.post.mjs.map
