import { d as defineEventHandler, h as getServerConfig, p as prisma } from '../../nitro/nitro.mjs';
import { stat } from 'fs/promises';
import { join } from 'path';
import 'node:http';
import 'node:https';
import 'node:crypto';
import 'stream';
import 'events';
import 'http';
import 'crypto';
import 'buffer';
import 'zlib';
import 'https';
import 'net';
import 'tls';
import 'url';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'vue-router';
import '@prisma/client';
import '@prisma/adapter-better-sqlite3';
import 'fs';
import 'child_process';
import 'node:child_process';
import 'node:url';

const health_get = defineEventHandler(async () => {
  const config = getServerConfig();
  const checks = {};
  try {
    const dbPath = join(config.autocodeRoot, "autocode.db");
    await stat(dbPath);
    checks["database"] = true;
  } catch {
    checks["database"] = false;
  }
  try {
    await prisma.$queryRaw`SELECT 1`;
    checks["databaseConnection"] = true;
  } catch {
    checks["databaseConnection"] = false;
  }
  try {
    const attachmentsPath = join(config.autocodeRoot, "attachments");
    await stat(attachmentsPath);
    checks["attachments"] = true;
  } catch {
    checks["attachments"] = false;
  }
  const healthy = checks["database"] && checks["databaseConnection"];
  return {
    healthy,
    checks,
    timestamp: (/* @__PURE__ */ new Date()).toISOString()
  };
});

export { health_get as default };
//# sourceMappingURL=health.get.mjs.map
